MCPcopy
hub / github.com/psycopg/psycopg / test_configure

Function test_configure

tests/pool/test_pool_async.py:176–201  ·  view source on GitHub ↗
(dsn)

Source from the content-addressed store, hash-verified

174
175
176async def test_configure(dsn):
177 inits = 0
178
179 async def configure(conn):
180 nonlocal inits
181 inits += 1
182 async with conn.transaction():
183 await conn.execute("set default_transaction_read_only to on")
184
185 async with pool.AsyncConnectionPool(dsn, min_size=1, configure=configure) as p:
186 await p.wait(timeout=1.0)
187 async with p.connection() as conn:
188 assert inits == 1
189 res = await conn.execute("show default_transaction_read_only")
190 assert (await res.fetchone())[0] == "on"
191
192 async with p.connection() as conn:
193 assert inits == 1
194 res = await conn.execute("show default_transaction_read_only")
195 assert (await res.fetchone())[0] == "on"
196 await conn.close()
197
198 async with p.connection() as conn:
199 assert inits == 2
200 res = await conn.execute("show default_transaction_read_only")
201 assert (await res.fetchone())[0] == "on"
202
203
204async def test_reset(dsn):

Callers

nothing calls this directly

Calls 5

waitMethod · 0.45
connectionMethod · 0.45
executeMethod · 0.45
fetchoneMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected