MCPcopy
hub / github.com/psycopg/psycopg / test_context_active_rollback_no_clobber

Function test_context_active_rollback_no_clobber

tests/test_transaction_async.py:112–129  ·  view source on GitHub ↗
(aconn_cls, dsn, caplog)

Source from the content-addressed store, hash-verified

110
111@pytest.mark.crdb_skip("copy")
112async def test_context_active_rollback_no_clobber(aconn_cls, dsn, caplog):
113 caplog.set_level(logging.WARNING, logger="psycopg")
114
115 conn = await aconn_cls.connect(dsn)
116 try:
117 with pytest.raises(ZeroDivisionError):
118 async with conn.transaction():
119 conn.pgconn.exec_(b"copy (select generate_series(1, 10)) to stdout")
120 status = conn.info.transaction_status
121 assert status == pq.TransactionStatus.ACTIVE
122 1 / 0
123
124 assert len(caplog.records) == 1
125 rec = caplog.records[0]
126 assert rec.levelno == logging.WARNING
127 assert "in rollback" in rec.message
128 finally:
129 await conn.close()
130
131
132async def test_interaction_dbapi_transaction(aconn):

Callers

nothing calls this directly

Calls 4

connectMethod · 0.45
transactionMethod · 0.45
exec_Method · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…