| 382 | |
| 383 | |
| 384 | async def test_auto_transaction(aconn): |
| 385 | aconn.pgconn.exec_(b"drop table if exists foo") |
| 386 | aconn.pgconn.exec_(b"create table foo (id int primary key)") |
| 387 | |
| 388 | cur = aconn.cursor() |
| 389 | assert aconn.pgconn.transaction_status == pq.TransactionStatus.IDLE |
| 390 | |
| 391 | await cur.execute("insert into foo values (1)") |
| 392 | assert aconn.pgconn.transaction_status == pq.TransactionStatus.INTRANS |
| 393 | |
| 394 | await aconn.commit() |
| 395 | assert aconn.pgconn.transaction_status == pq.TransactionStatus.IDLE |
| 396 | await cur.execute("select * from foo") |
| 397 | assert await cur.fetchone() == (1,) |
| 398 | assert aconn.pgconn.transaction_status == pq.TransactionStatus.INTRANS |
| 399 | |
| 400 | |
| 401 | async def test_auto_transaction_fail(aconn): |