]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- modify how class state is tracked here as it seems like things
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 15 Aug 2014 04:19:32 +0000 (00:19 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 15 Aug 2014 04:19:32 +0000 (00:19 -0400)
are a little more crazy under xdist mode

lib/sqlalchemy/testing/plugin/pytestplugin.py

index fd06163276adf6fdbbf98b276ef11f3cbe58fed8..f4c9efd554d3e06d7e6353e62185ec1b25e8182c 100644 (file)
@@ -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)