Skip to content

Commit b119a8a

Browse files
committed
Revert "Fix SesstionTransaction._connection_for_bind call"
This reverts commit b12b641.
1 parent 42a793e commit b119a8a

File tree

2 files changed

+1
-36
lines changed

2 files changed

+1
-36
lines changed

pytest_flask_sqlalchemy/fixtures.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import contextlib
21
import os
2+
import contextlib
33

44
import pytest
55
import sqlalchemy as sa
@@ -153,12 +153,6 @@ def raw_connection():
153153

154154
engine.raw_connection = raw_connection
155155

156-
# Fix SessionTransaction._connection_for_bind caching
157-
@sa.event.listens_for(session, 'after_begin')
158-
def after_begin(session, transaction, conn):
159-
if engine not in transaction._connections:
160-
transaction._connections[engine] = transaction._connections[conn]
161-
162156
for mocked_engine in pytestconfig._mocked_engines:
163157
mocker.patch(mocked_engine, new=engine)
164158

tests/test_fixtures.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -336,32 +336,3 @@ def test_delete_message(account_address, db_session):
336336

337337
result = db_testdir.runpytest()
338338
result.assert_outcomes(passed=1)
339-
340-
341-
def test_rollback_nested(db_testdir):
342-
'''
343-
Test that creating objects and emitting SQL in the ORM won't bleed into
344-
other tests.
345-
'''
346-
# Load tests from file
347-
db_testdir.makepyfile("""
348-
def test_rollback_nested(person, db_session, caplog):
349-
assert db_session.query(person).count() == 0
350-
n1 = db_session.begin_nested()
351-
db_session.add(person())
352-
assert db_session.query(person).count() == 1
353-
354-
n2 = db_session.begin_nested()
355-
db_session.add(person())
356-
assert db_session.query(person).count() == 2
357-
358-
n2.rollback()
359-
print(db_session.bind.mock_calls)
360-
assert db_session.query(person).count() == 1
361-
n1.rollback()
362-
assert db_session.query(person).count() == 0
363-
""")
364-
365-
# Run tests
366-
result = db_testdir.runpytest()
367-
result.assert_outcomes(passed=1)

0 commit comments

Comments
 (0)