(self)
| 658 | conn.execution_options(isolation_level="AUTOCOMMIT") |
| 659 | |
| 660 | def test_autobegin_commit(self): |
| 661 | users = self.tables.users |
| 662 | |
| 663 | with testing.db.connect() as conn: |
| 664 | assert not conn.in_transaction() |
| 665 | conn.execute(users.insert(), {"user_id": 1, "user_name": "name"}) |
| 666 | |
| 667 | assert conn.in_transaction() |
| 668 | conn.commit() |
| 669 | |
| 670 | assert not conn.in_transaction() |
| 671 | |
| 672 | eq_( |
| 673 | conn.scalar(select(func.count(1)).select_from(users)), |
| 674 | 1, |
| 675 | ) |
| 676 | |
| 677 | conn.execute(users.insert(), {"user_id": 2, "user_name": "name 2"}) |
| 678 | |
| 679 | eq_( |
| 680 | conn.scalar(select(func.count(1)).select_from(users)), |
| 681 | 2, |
| 682 | ) |
| 683 | |
| 684 | assert conn.in_transaction() |
| 685 | conn.rollback() |
| 686 | assert not conn.in_transaction() |
| 687 | |
| 688 | eq_( |
| 689 | conn.scalar(select(func.count(1)).select_from(users)), |
| 690 | 1, |
| 691 | ) |
| 692 | |
| 693 | def test_rollback_on_close(self): |
| 694 | canary = mock.Mock() |
nothing calls this directly
no test coverage detected