MCPcopy
hub / github.com/psycopg/psycopg / test_rollback

Function test_rollback

tests/test_connection.py:372–385  ·  view source on GitHub ↗
(conn)

Source from the content-addressed store, hash-verified

370
371
372def test_rollback(conn):
373 conn.pgconn.exec_(b"drop table if exists foo")
374 conn.pgconn.exec_(b"create table foo (id int primary key)")
375 conn.pgconn.exec_(b"begin")
376 assert conn.pgconn.transaction_status == pq.TransactionStatus.INTRANS
377 conn.pgconn.exec_(b"insert into foo values (1)")
378 conn.rollback()
379 assert conn.pgconn.transaction_status == pq.TransactionStatus.IDLE
380 res = conn.pgconn.exec_(b"select id from foo where id = 1")
381 assert res.ntuples == 0
382
383 conn.close()
384 with pytest.raises(psycopg.OperationalError):
385 conn.rollback()
386
387
388def test_auto_transaction(conn):

Callers

nothing calls this directly

Calls 3

exec_Method · 0.45
rollbackMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected