diff options
| author | Rodrigo Menezes <rodrigo.menezes@moat.com> | 2014-08-26 12:57:00 -0400 |
|---|---|---|
| committer | Rodrigo Menezes <rodrigo.menezes@moat.com> | 2014-08-26 12:57:00 -0400 |
| commit | b3f7cd8bf497febb80e6cd7dc39effc75ff1a7e7 (patch) | |
| tree | e3a022b20405768bb4e1912c9a2f1347b751d64c /lib/sqlalchemy/testing/plugin/pytestplugin.py | |
| parent | bcf7a55da01633c4890502463a08cb96af9fe5e9 (diff) | |
| parent | 8e84942aa6fa2644b3fe6407c79449715a7e2c8c (diff) | |
| download | sqlalchemy-b3f7cd8bf497febb80e6cd7dc39effc75ff1a7e7.tar.gz | |
Merge branch 'master' of https://github.com/zzzeek/sqlalchemy into feature/postgres-relkind
Diffstat (limited to 'lib/sqlalchemy/testing/plugin/pytestplugin.py')
| -rw-r--r-- | lib/sqlalchemy/testing/plugin/pytestplugin.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index fd0616327..005942913 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -74,6 +74,9 @@ def pytest_collection_modifyitems(session, config, items): # new classes to a module on the fly. rebuilt_items = collections.defaultdict(list) + items[:] = [ + item for item in + items if isinstance(item.parent, pytest.Instance)] test_classes = set(item.parent for item in items) for test_class in test_classes: for sub_cls in plugin_base.generate_sub_tests( @@ -115,7 +118,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 +128,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) |
