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

Function test_commit_error

tests/test_connection_async.py:351–365  ·  view source on GitHub ↗
(aconn)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

executeMethod · 0.45
commitMethod · 0.45
fetchoneMethod · 0.45

Tested by

no test coverage detected