MCPcopy
hub / github.com/psycopg/psycopg / test_commit_error

Function test_commit_error

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

Source from the content-addressed store, hash-verified

353
354@pytest.mark.crdb_skip("deferrable")
355def test_commit_error(conn):
356 conn.execute("""
357 drop table if exists selfref;
358 create table selfref (
359 x serial primary key,
360 y int references selfref (x) deferrable initially deferred)
361 """)
362 conn.commit()
363
364 conn.execute("insert into selfref (y) values (-1)")
365 with pytest.raises(e.ForeignKeyViolation):
366 conn.commit()
367 assert conn.pgconn.transaction_status == pq.TransactionStatus.IDLE
368 cur = conn.execute("select 1")
369 assert cur.fetchone() == (1,)
370
371
372def test_rollback(conn):

Callers

nothing calls this directly

Calls 3

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…