MCPcopy
hub / github.com/psycopg/psycopg / test_context_rollback

Function test_context_rollback

tests/test_connection.py:270–283  ·  view source on GitHub ↗
(conn_cls, conn, dsn)

Source from the content-addressed store, hash-verified

268
269@pytest.mark.usefixtures("testctx")
270def test_context_rollback(conn_cls, conn, dsn):
271 with pytest.raises(ZeroDivisionError):
272 with conn:
273 with conn.cursor() as cur:
274 cur.execute("insert into testctx values (42)")
275 1 / 0
276
277 assert conn.closed
278 assert not conn.broken
279
280 with conn_cls.connect(dsn) as conn:
281 with conn.cursor() as cur:
282 cur.execute("select * from testctx")
283 assert cur.fetchall() == []
284
285
286def test_context_close(conn):

Callers

nothing calls this directly

Calls 4

cursorMethod · 0.45
executeMethod · 0.45
connectMethod · 0.45
fetchallMethod · 0.45

Tested by

no test coverage detected