MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / connection

Method connection

lib/sqlalchemy/testing/fixtures/base.py:74–92  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

72
73 @config.fixture()
74 def connection(self):
75 global _connection_fixture_connection
76
77 eng = getattr(self, "bind", None) or config.db
78
79 conn = eng.connect()
80 trans = conn.begin()
81
82 _connection_fixture_connection = conn
83 yield conn
84
85 _connection_fixture_connection = None
86
87 if trans.is_active:
88 trans.rollback()
89 # trans would not be active here if the test is using
90 # the legacy @provide_metadata decorator still, as it will
91 # run a close all connections.
92 conn.close()
93
94 @config.fixture()
95 def close_result_when_finished(self):

Callers

nothing calls this directly

Calls 4

connectMethod · 0.45
beginMethod · 0.45
rollbackMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected