MCPcopy
hub / github.com/psycopg/psycopg / test_rollback_on_exception_exit

Function test_rollback_on_exception_exit

tests/test_transaction_async.py:74–82  ·  view source on GitHub ↗

Changes are rolled back if an exception escapes the `with` block.

(aconn)

Source from the content-addressed store, hash-verified

72
73
74async def test_rollback_on_exception_exit(aconn):
75 """Changes are rolled back if an exception escapes the `with` block."""
76 with pytest.raises(ExpectedException):
77 async with aconn.transaction():
78 await insert_row(aconn, "foo")
79 raise ExpectedException("This discards the insert")
80
81 assert not in_transaction(aconn)
82 assert not await inserted(aconn)
83
84
85@pytest.mark.crdb_skip("pg_terminate_backend")

Callers

nothing calls this directly

Calls 5

insert_rowFunction · 0.85
ExpectedExceptionClass · 0.85
in_transactionFunction · 0.85
insertedFunction · 0.85
transactionMethod · 0.45

Tested by

no test coverage detected