diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-15 00:19:32 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-15 00:19:32 -0400 |
commit | b952d892d690ec808829aede84769b2bf089f94d (patch) | |
tree | 9eb348ad38497e5d2ce536088dff6acb310a130d /lib/sqlalchemy/testing/plugin/pytestplugin.py | |
parent | bc509dd50d7b65e35412e2be67bd37a6c19e7119 (diff) | |
download | sqlalchemy-b952d892d690ec808829aede84769b2bf089f94d.tar.gz |
- modify how class state is tracked here as it seems like things
are a little more crazy under xdist mode
Diffstat (limited to 'lib/sqlalchemy/testing/plugin/pytestplugin.py')
-rw-r--r-- | lib/sqlalchemy/testing/plugin/pytestplugin.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index fd0616327..f4c9efd55 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -115,7 +115,6 @@ def pytest_pycollect_makeitem(collector, name, obj): _current_class = None - def pytest_runtest_setup(item): # here we seem to get called only based on what we collected # in pytest_collection_modifyitems. So to do class-based stuff @@ -126,16 +125,18 @@ def pytest_runtest_setup(item): return # ... so we're doing a little dance here to figure it out... - if item.parent.parent is not _current_class: - + if _current_class is None: class_setup(item.parent.parent) _current_class = item.parent.parent # this is needed for the class-level, to ensure that the # teardown runs after the class is completed with its own # class-level teardown... - item.parent.parent.addfinalizer( - lambda: class_teardown(item.parent.parent)) + def finalize(): + global _current_class + class_teardown(item.parent.parent) + _current_class = None + item.parent.parent.addfinalizer(finalize) test_setup(item) |