diff --git a/tests/conftest.py b/tests/conftest.py index b66e02672934..cc0847bdc8b0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -702,7 +702,20 @@ def xmlrpc(self, path, method, *args): @pytest.fixture -def webtest(app_config_dbsession_from_env, remote_addr): +def tm(): + # Create a new transaction manager for dependant test cases + tm = transaction.TransactionManager(explicit=True) + tm.begin() + tm.doom() + + yield tm + + # Abort the transaction, leaving database in previous state + tm.abort() + + +@pytest.fixture +def webtest(app_config_dbsession_from_env, remote_addr, tm): """ This fixture yields a test app with an alternative Pyramid configuration, injecting the database session and transaction manager into the app. @@ -718,11 +731,6 @@ def webtest(app_config_dbsession_from_env, remote_addr): app = app_config_dbsession_from_env.make_wsgi_app() - # Create a new transaction manager for dependant test cases - tm = transaction.TransactionManager(explicit=True) - tm.begin() - tm.doom() - with get_db_session_for_app_config(app_config_dbsession_from_env) as _db_session: # Register the app with the external test environment, telling # request.db to use this db_session and use the Transaction manager. @@ -737,9 +745,6 @@ def webtest(app_config_dbsession_from_env, remote_addr): ) yield testapp - # Abort the transaction, leaving database in previous state - tm.abort() - class _MockRedis: """