| 336 | |
| 337 | |
| 338 | def 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") |