Skip to content

Commit 88f95d5

Browse files
committed
PYTHON-2635 Unpin sessions after all abortTransaction attempts (#609)
Add unified test runner for transactions. (cherry picked from commit 61c6876)
1 parent cb20aad commit 88f95d5

35 files changed

+386
-4
lines changed

pymongo/client_session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ def abort_transaction(self):
660660
pass
661661
finally:
662662
self._transaction.state = _TxnState.ABORTED
663+
self._unpin_mongos()
663664

664665
def _finish_transaction_with_retry(self, command_name):
665666
"""Run commit or abort with one retry after any retryable error.

test/test_transactions.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@
3939
wait_until, OvertCommandListener,
4040
TestCreator)
4141
from test.utils_spec_runner import SpecRunner
42+
from test.unified_format import generate_test_classes
4243

4344
# Location of JSON test specifications.
44-
_TEST_PATH = os.path.join(
45-
os.path.dirname(os.path.realpath(__file__)), 'transactions')
45+
TEST_PATH = os.path.join(
46+
os.path.dirname(os.path.realpath(__file__)), 'transactions', 'legacy')
47+
UNIFIED_TEST_PATH = os.path.join(
48+
os.path.dirname(os.path.realpath(__file__)), 'transactions', 'unified')
4649

4750
_TXN_TESTS_DEBUG = os.environ.get('TRANSACTION_TESTS_DEBUG')
4851

@@ -466,13 +469,17 @@ def run_scenario(self):
466469
return run_scenario
467470

468471

469-
test_creator = TestCreator(create_test, TestTransactions, _TEST_PATH)
472+
test_creator = TestCreator(create_test, TestTransactions, TEST_PATH)
470473
test_creator.create_tests()
471474

472475

473476
TestCreator(create_test, TestTransactionsConvenientAPI,
474477
TestTransactionsConvenientAPI.TEST_PATH).create_tests()
475478

476479

480+
# Generate unified tests.
481+
globals().update(generate_test_classes(UNIFIED_TEST_PATH, module=__name__))
482+
483+
477484
if __name__ == "__main__":
478485
unittest.main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)