MCPcopy
hub / github.com/psycopg/psycopg / test_intrans_rollback

Function test_intrans_rollback

tests/pool/test_pool_async.py:277–296  ·  view source on GitHub ↗
(dsn, caplog)

Source from the content-addressed store, hash-verified

275
276@pytest.mark.crdb_skip("backend pid")
277async def test_intrans_rollback(dsn, caplog):
278 caplog.set_level(logging.WARNING, logger="psycopg.pool")
279
280 async with pool.AsyncConnectionPool(dsn, min_size=1) as p:
281 conn = await p.getconn()
282 pid = conn.info.backend_pid
283 await conn.execute("create table test_intrans_rollback ()")
284 assert conn.info.transaction_status == TransactionStatus.INTRANS
285 await p.putconn(conn)
286
287 async with p.connection() as conn2:
288 assert conn2.info.backend_pid == pid
289 assert conn2.info.transaction_status == TransactionStatus.IDLE
290 cur = await conn2.execute(
291 "select 1 from pg_class where relname = 'test_intrans_rollback'"
292 )
293 assert not await cur.fetchone()
294
295 assert len(caplog.records) == 1
296 assert "INTRANS" in caplog.records[0].message
297
298
299@pytest.mark.crdb_skip("backend pid")

Callers

nothing calls this directly

Calls 5

getconnMethod · 0.45
executeMethod · 0.45
putconnMethod · 0.45
connectionMethod · 0.45
fetchoneMethod · 0.45

Tested by

no test coverage detected