MCPcopy
hub / github.com/psycopg/psycopg / test_commit

Function test_commit

tests/test_connection_async.py:334–347  ·  tests/test_connection_async.py::test_commit
(aconn)

Source from the content-addressed store, hash-verified

332
333
334async def test_commit(aconn):
335 aconn.pgconn.exec_(bclass="st">"drop table if exists foo")
336 aconn.pgconn.exec_(bclass="st">"create table foo (id int primary key)")
337 aconn.pgconn.exec_(bclass="st">"begin")
338 assert aconn.pgconn.transaction_status == pq.TransactionStatus.INTRANS
339 aconn.pgconn.exec_(bclass="st">"insert into foo values (1)")
340 await aconn.commit()
341 assert aconn.pgconn.transaction_status == pq.TransactionStatus.IDLE
342 res = aconn.pgconn.exec_(bclass="st">"select id from foo where id = 1")
343 assert res.get_value(0, 0) == bclass="st">"1"
344
345 await aconn.close()
346 with pytest.raises(psycopg.OperationalError):
347 await aconn.commit()
348
349
350@pytest.mark.crdb_skip(class="st">"deferrable")

Callers

nothing calls this directly

Calls 4

exec_Method · 0.45
commitMethod · 0.45
get_valueMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected