diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 4a13752bd..842026839 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.2.2.dev4' +__version__ = '2.2.2.dev5' diff --git a/_pytest/python.py b/_pytest/python.py index 242d46b21..770524984 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -221,9 +221,9 @@ class PyCollectorMixin(PyobjMixin, pytest.Collector): module = self.getparent(Module).obj clscol = self.getparent(Class) cls = clscol and clscol.obj or None + transfer_markers(funcobj, cls, module) metafunc = Metafunc(funcobj, config=self.config, cls=cls, module=module) - transfer_markers(metafunc) gentesthook = self.config.hook.pytest_generate_tests extra = [module] if cls is not None: @@ -241,20 +241,19 @@ class PyCollectorMixin(PyobjMixin, pytest.Collector): l.append(function) return l -def transfer_markers(metafunc): +def transfer_markers(funcobj, cls, mod): # XXX this should rather be code in the mark plugin or the mark # plugin should merge with the python plugin. - for holder in (metafunc.cls, metafunc.module): + for holder in (cls, mod): try: pytestmark = holder.pytestmark except AttributeError: continue if isinstance(pytestmark, list): for mark in pytestmark: - mark(metafunc.function) + mark(funcobj) else: - pytestmark(metafunc.function) - + pytestmark(funcobj) class Module(pytest.File, PyCollectorMixin): def _getobj(self): diff --git a/_pytest/unittest.py b/_pytest/unittest.py index d4ca5575b..d4a2ba0c3 100644 --- a/_pytest/unittest.py +++ b/_pytest/unittest.py @@ -2,6 +2,9 @@ import pytest, py import sys, pdb +# for transfering markers +from _pytest.python import transfer_markers + def pytest_pycollect_makeitem(collector, name, obj): unittest = sys.modules.get('unittest') if unittest is None: @@ -19,7 +22,12 @@ def pytest_pycollect_makeitem(collector, name, obj): class UnitTestCase(pytest.Class): def collect(self): loader = py.std.unittest.TestLoader() + module = self.getparent(pytest.Module).obj + cls = self.obj for name in loader.getTestCaseNames(self.obj): + x = getattr(self.obj, name) + funcobj = getattr(x, 'im_func', x) + transfer_markers(funcobj, cls, module) yield TestCaseFunction(name, parent=self) def setup(self): diff --git a/setup.py b/setup.py index c2b746505..b19ea6064 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.2.2.dev4', + version='2.2.2.dev5', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],