MCPcopy
hub / github.com/psycopg/psycopg / test_dump_cursor_ctx

Function test_dump_cursor_ctx

tests/test_adapt.py:102–123  ·  view source on GitHub ↗
(conn)

Source from the content-addressed store, hash-verified

100
101
102def test_dump_cursor_ctx(conn):
103 conn.adapters.register_dumper(str, make_bin_dumper("b"))
104 conn.adapters.register_dumper(str, make_dumper("t"))
105
106 cur = conn.cursor()
107 cur.adapters.register_dumper(str, make_bin_dumper("bc"))
108 cur.adapters.register_dumper(str, make_dumper("tc"))
109
110 cur.execute("select %s", [MyStr("hello")])
111 assert cur.fetchone() == ("hellotc",)
112 cur.execute("select %t", [MyStr("hello")])
113 assert cur.fetchone() == ("hellotc",)
114 cur.execute("select %b", [MyStr("hello")])
115 assert cur.fetchone() == ("hellobc",)
116
117 cur = conn.cursor()
118 cur.execute("select %s", [MyStr("hello")])
119 assert cur.fetchone() == ("hellot",)
120 cur.execute("select %t", [MyStr("hello")])
121 assert cur.fetchone() == ("hellot",)
122 cur.execute("select %b", [MyStr("hello")])
123 assert cur.fetchone() == ("hellob",)
124
125
126def test_dump_subclass(conn):

Callers

nothing calls this directly

Calls 7

make_bin_dumperFunction · 0.85
make_dumperFunction · 0.85
MyStrClass · 0.85
register_dumperMethod · 0.80
cursorMethod · 0.45
executeMethod · 0.45
fetchoneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…