MCPcopy
hub / github.com/psycopg/psycopg / test_auto_transaction

Function test_auto_transaction

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

Source from the content-addressed store, hash-verified

386
387
388def test_auto_transaction(conn):
389 conn.pgconn.exec_(b"drop table if exists foo")
390 conn.pgconn.exec_(b"create table foo (id int primary key)")
391
392 cur = conn.cursor()
393 assert conn.pgconn.transaction_status == pq.TransactionStatus.IDLE
394
395 cur.execute("insert into foo values (1)")
396 assert conn.pgconn.transaction_status == pq.TransactionStatus.INTRANS
397
398 conn.commit()
399 assert conn.pgconn.transaction_status == pq.TransactionStatus.IDLE
400 cur.execute("select * from foo")
401 assert cur.fetchone() == (1,)
402 assert conn.pgconn.transaction_status == pq.TransactionStatus.INTRANS
403
404
405def test_auto_transaction_fail(conn):

Callers

nothing calls this directly

Calls 5

exec_Method · 0.45
cursorMethod · 0.45
executeMethod · 0.45
commitMethod · 0.45
fetchoneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…