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

Function test_commit

tests/test_connection.py:338–351  ·  tests/test_connection.py::test_commit
(conn)

Source from the content-addressed store, hash-verified

336
337
338def test_commit(conn):
339 conn.pgconn.exec_(bclass="st">"drop table if exists foo")
340 conn.pgconn.exec_(bclass="st">"create table foo (id int primary key)")
341 conn.pgconn.exec_(bclass="st">"begin")
342 assert conn.pgconn.transaction_status == pq.TransactionStatus.INTRANS
343 conn.pgconn.exec_(bclass="st">"insert into foo values (1)")
344 conn.commit()
345 assert conn.pgconn.transaction_status == pq.TransactionStatus.IDLE
346 res = conn.pgconn.exec_(bclass="st">"select id from foo where id = 1")
347 assert res.get_value(0, 0) == bclass="st">"1"
348
349 conn.close()
350 with pytest.raises(psycopg.OperationalError):
351 conn.commit()
352
353
354@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