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

Function test_commit_error

tests/test_connection.py:355–369  ·  tests/test_connection.py::test_commit_error
(conn)

Source from the content-addressed store, hash-verified

353
354@pytest.mark.crdb_skip(class="st">"deferrable")
355def test_commit_error(conn):
356 conn.execute(class="st">"""
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 class="st">""")
362 conn.commit()
363
364 conn.execute(class="st">"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(class="st">"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