correctly handle nose.SkipTest during collection
This commit is contained in:
parent
5ba2a7f628
commit
37c47155e0
|
@ -347,6 +347,18 @@ class Collector(Node):
|
||||||
""" Collector instances create children through collect()
|
""" Collector instances create children through collect()
|
||||||
and thus iteratively build a tree.
|
and thus iteratively build a tree.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_skip_exceptions = None
|
||||||
|
@property
|
||||||
|
def skip_exceptions(self):
|
||||||
|
if self._skip_exceptions is None:
|
||||||
|
return (py.test.skip.Exception,)
|
||||||
|
return self._skip_exceptions
|
||||||
|
|
||||||
|
@skip_exceptions.setter
|
||||||
|
def skip_exceptions(self, value):
|
||||||
|
self._skip_exceptions = value
|
||||||
|
|
||||||
class CollectError(Exception):
|
class CollectError(Exception):
|
||||||
""" an error during collection, contains a custom message. """
|
""" an error during collection, contains a custom message. """
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ def pytest_runtest_teardown(item):
|
||||||
# del item.parent._nosegensetup
|
# del item.parent._nosegensetup
|
||||||
|
|
||||||
def pytest_make_collect_report(collector):
|
def pytest_make_collect_report(collector):
|
||||||
|
SkipTest = py.std.unittest.SkipTest
|
||||||
|
collector.skip_exceptions += (SkipTest,)
|
||||||
if isinstance(collector, pytest.Generator):
|
if isinstance(collector, pytest.Generator):
|
||||||
call_optional(collector.obj, 'setup')
|
call_optional(collector.obj, 'setup')
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ def pytest_make_collect_report(collector):
|
||||||
if not call.excinfo:
|
if not call.excinfo:
|
||||||
outcome = "passed"
|
outcome = "passed"
|
||||||
else:
|
else:
|
||||||
if call.excinfo.errisinstance(py.test.skip.Exception):
|
if call.excinfo.errisinstance(collector.skip_exceptions):
|
||||||
outcome = "skipped"
|
outcome = "skipped"
|
||||||
r = collector._repr_failure_py(call.excinfo, "line").reprcrash
|
r = collector._repr_failure_py(call.excinfo, "line").reprcrash
|
||||||
longrepr = (str(r.path), r.lineno, r.message)
|
longrepr = (str(r.path), r.lineno, r.message)
|
||||||
|
|
|
@ -305,3 +305,12 @@ def test_apiwrapper_problem_issue260(testdir):
|
||||||
result.stdout.fnmatch_lines("*1 passed*")
|
result.stdout.fnmatch_lines("*1 passed*")
|
||||||
|
|
||||||
|
|
||||||
|
def test_SkipTest_during_collection(testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import nose
|
||||||
|
raise nose.SkipTest("during collection")
|
||||||
|
def test_failing():
|
||||||
|
assert False
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest()
|
||||||
|
result.stdout.fnmatch_lines("*1 skipped*")
|
||||||
|
|
Loading…
Reference in New Issue