MCPcopy Create free account
hub / github.com/zzzeek/sqlalchemy / test_autobegin_commit

Method test_autobegin_commit

test/engine/test_transaction.py:660–691  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 11

eq_Function · 0.90
selectFunction · 0.90
connectMethod · 0.45
in_transactionMethod · 0.45
executeMethod · 0.45
insertMethod · 0.45
commitMethod · 0.45
scalarMethod · 0.45
select_fromMethod · 0.45
countMethod · 0.45
rollbackMethod · 0.45

Tested by

no test coverage detected