summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-03-03 02:23:53 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-03-03 02:23:53 -0500
commit46f4cfd269bdde34f40d782f7d99b442f3547822 (patch)
tree408989210521be58e3bfaa040f9e87461d0c6262 /lib/sqlalchemy/testing
parent4a29a3cd5605b68d7f7183c7947fb83ed6a9a21e (diff)
downloadsqlalchemy-46f4cfd269bdde34f40d782f7d99b442f3547822.tar.gz
- go through a more complex process here to work around a dict reordering issue in pytest
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/plugin/noseplugin.py1
-rw-r--r--lib/sqlalchemy/testing/plugin/plugin_base.py3
-rw-r--r--lib/sqlalchemy/testing/plugin/pytestplugin.py39
3 files changed, 38 insertions, 5 deletions
diff --git a/lib/sqlalchemy/testing/plugin/noseplugin.py b/lib/sqlalchemy/testing/plugin/noseplugin.py
index 2318d6176..0e8676b49 100644
--- a/lib/sqlalchemy/testing/plugin/noseplugin.py
+++ b/lib/sqlalchemy/testing/plugin/noseplugin.py
@@ -15,6 +15,7 @@ import os
from nose.plugins import Plugin
from nose import SkipTest
+fixtures = None
# no package imports yet! this prevents us from tripping coverage
# too soon.
diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py
index fd8d46e9c..6fd2e7f33 100644
--- a/lib/sqlalchemy/testing/plugin/plugin_base.py
+++ b/lib/sqlalchemy/testing/plugin/plugin_base.py
@@ -352,9 +352,6 @@ def after_test(test):
warnings.resetwarnings()
def _do_skips(cls):
- if cls is None:
- import pdb
- pdb.set_trace()
all_configs = set(config.Config.all_configs())
reasons = []
diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py
index 735130fb4..d1c3c47d3 100644
--- a/lib/sqlalchemy/testing/plugin/pytestplugin.py
+++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py
@@ -29,13 +29,48 @@ def pytest_configure(config):
global py_unittest
py_unittest = config.pluginmanager.getplugin('unittest')
+import collections
+def pytest_collection_modifyitems(session, config, items):
+ # look for all those classes that specify __multiple__ and
+ # expand them out into per-database test cases.
+
+ # this is much easier to do within pytest_pycollect_makeitem, however
+ # pytest is unfortunately iterating through cls.__dict__ as makeitem is
+ # called which causes a "dictionary changed size" error on py3k.
+ # I'd submit a pullreq for them to turn it into a list first, but
+ # it's to suit the rather odd use case here which is that we are adding
+ # new classes to a module on the flt.
+
+ rebuilt_items = collections.defaultdict(list)
+
+ test_classes = set(item.parent for item in items)
+ for test_class in test_classes:
+ for sub_cls in plugin_base.generate_sub_tests(test_class.cls, test_class.parent.module):
+ if sub_cls is not test_class.cls:
+ rebuilt_items[test_class.cls].extend(py_unittest.UnitTestCase(
+ sub_cls.__name__, parent=test_class.parent).collect())
+
+ newitems = []
+ for item in items:
+ if item.parent.cls in rebuilt_items:
+ #import pdb
+ #pdb.set_trace()
+ newitems.extend(rebuilt_items[item.parent.cls])
+ rebuilt_items[item.parent.cls][:] = []
+ else:
+ newitems.append(item)
+
+ items[:] = newitems
def pytest_pycollect_makeitem(collector, name, obj):
if inspect.isclass(obj) and plugin_base.want_class(obj):
+ return py_unittest.UnitTestCase(name, parent=collector)
return [
py_unittest.UnitTestCase(sub_obj.__name__, parent=collector)
for sub_obj in plugin_base.generate_sub_tests(obj, collector.module)
]
+ else:
+ return []
_current_class = None
@@ -80,8 +115,8 @@ def class_setup(item):
try:
plugin_base.start_test_class(item.cls)
except plugin_base.GenericSkip as gs:
- print(gs.message)
- pytest.skip(gs.message)
+ print(gs)
+ pytest.skip(str(gs))
def class_teardown(item):
plugin_base.stop_test_class(item.cls)