MCPcopy
hub / github.com/psycopg/psycopg / test_reset

Function test_reset

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

Source from the content-addressed store, hash-verified

202
203
204async def test_reset(dsn):
205 resets = 0
206
207 async def setup(conn):
208 async with conn.transaction():
209 await conn.execute("set timezone to '+1:00'")
210
211 async def reset(conn):
212 nonlocal resets
213 resets += 1
214 async with conn.transaction():
215 await conn.execute("set timezone to utc")
216
217 async with pool.AsyncConnectionPool(dsn, min_size=1, reset=reset) as p:
218 async with p.connection() as conn:
219 assert resets == 0
220 await conn.execute("set timezone to '+2:00'")
221
222 await p.wait()
223 assert resets == 1
224
225 async with p.connection() as conn:
226 cur = await conn.execute("show timezone")
227 assert (await cur.fetchone()) == ("UTC",)
228
229 await p.wait()
230 assert resets == 2
231
232
233@pytest.mark.crdb_skip("backend pid")

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected