summaryrefslogtreecommitdiff
path: root/lib/spack/external/_pytest/nose.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/external/_pytest/nose.py')
-rw-r--r--lib/spack/external/_pytest/nose.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/spack/external/_pytest/nose.py b/lib/spack/external/_pytest/nose.py
index 0387468686..d246c5603d 100644
--- a/lib/spack/external/_pytest/nose.py
+++ b/lib/spack/external/_pytest/nose.py
@@ -1,10 +1,11 @@
""" run test suites written for nose. """
+from __future__ import absolute_import, division, print_function
import sys
import py
-import pytest
-from _pytest import unittest
+from _pytest import unittest, runner, python
+from _pytest.config import hookimpl
def get_skip_exceptions():
@@ -19,45 +20,46 @@ def get_skip_exceptions():
def pytest_runtest_makereport(item, call):
if call.excinfo and call.excinfo.errisinstance(get_skip_exceptions()):
# let's substitute the excinfo with a pytest.skip one
- call2 = call.__class__(lambda:
- pytest.skip(str(call.excinfo.value)), call.when)
+ call2 = call.__class__(
+ lambda: runner.skip(str(call.excinfo.value)), call.when)
call.excinfo = call2.excinfo
-@pytest.hookimpl(trylast=True)
+@hookimpl(trylast=True)
def pytest_runtest_setup(item):
if is_potential_nosetest(item):
- if isinstance(item.parent, pytest.Generator):
+ if isinstance(item.parent, python.Generator):
gen = item.parent
if not hasattr(gen, '_nosegensetup'):
call_optional(gen.obj, 'setup')
- if isinstance(gen.parent, pytest.Instance):
+ if isinstance(gen.parent, python.Instance):
call_optional(gen.parent.obj, 'setup')
gen._nosegensetup = True
if not call_optional(item.obj, 'setup'):
# call module level setup if there is no object level one
call_optional(item.parent.obj, 'setup')
- #XXX this implies we only call teardown when setup worked
+ # XXX this implies we only call teardown when setup worked
item.session._setupstate.addfinalizer((lambda: teardown_nose(item)), item)
+
def teardown_nose(item):
if is_potential_nosetest(item):
if not call_optional(item.obj, 'teardown'):
call_optional(item.parent.obj, 'teardown')
- #if hasattr(item.parent, '_nosegensetup'):
+ # if hasattr(item.parent, '_nosegensetup'):
# #call_optional(item._nosegensetup, 'teardown')
# del item.parent._nosegensetup
def pytest_make_collect_report(collector):
- if isinstance(collector, pytest.Generator):
+ if isinstance(collector, python.Generator):
call_optional(collector.obj, 'setup')
def is_potential_nosetest(item):
# extra check needed since we do not do nose style setup/teardown
# on direct unittest style classes
- return isinstance(item, pytest.Function) and \
+ return isinstance(item, python.Function) and \
not isinstance(item, unittest.TestCaseFunction)