MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_savepoint_seven

Method test_savepoint_seven

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

Source from the content-addressed store, hash-verified

1076
1077 @testing.requires.savepoints
1078 def test_savepoint_seven(self):
1079 users = self.tables.users
1080
1081 with testing.db.connect() as conn:
1082 trans = conn.begin()
1083 conn.execute(users.insert(), {"user_id": 1, "user_name": "name"})
1084
1085 sp1 = conn.begin_nested()
1086 conn.execute(users.insert(), {"user_id": 2, "user_name": "name2"})
1087
1088 sp2 = conn.begin_nested()
1089 conn.execute(users.insert(), {"user_id": 3, "user_name": "name3"})
1090
1091 assert conn.in_transaction()
1092
1093 trans.close()
1094
1095 assert not sp1.is_active
1096 assert not sp2.is_active
1097 assert not trans.is_active
1098 assert conn._transaction is None
1099 assert conn._nested_transaction is None
1100
1101 with testing.db.connect() as conn:
1102 eq_(
1103 conn.scalar(select(func.count(1)).select_from(users)),
1104 0,
1105 )
1106
1107
1108class AutoRollbackTest(fixtures.TestBase):

Callers

nothing calls this directly

Calls 12

eq_Function · 0.90
selectFunction · 0.90
connectMethod · 0.45
beginMethod · 0.45
executeMethod · 0.45
insertMethod · 0.45
begin_nestedMethod · 0.45
in_transactionMethod · 0.45
closeMethod · 0.45
scalarMethod · 0.45
select_fromMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected