3 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/8cf687dda7b0/ Changeset: 8cf687dda7b0 User: antocuni Date: 2013-03-14 16:10:33 Summary: correctly handle nose.SkipTest during collection Affected #: 4 files
diff -r 1944bf94e4648184bddcb5bbbbe8c02bcecd2184 -r 8cf687dda7b0c121f14332244b44135bf0407752 _pytest/main.py --- a/_pytest/main.py +++ b/_pytest/main.py @@ -347,6 +347,18 @@ """ Collector instances create children through collect() 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): """ an error during collection, contains a custom message. """ diff -r 1944bf94e4648184bddcb5bbbbe8c02bcecd2184 -r 8cf687dda7b0c121f14332244b44135bf0407752 _pytest/nose.py --- a/_pytest/nose.py +++ b/_pytest/nose.py @@ -38,6 +38,8 @@ # del item.parent._nosegensetup def pytest_make_collect_report(collector): + SkipTest = py.std.unittest.SkipTest + collector.skip_exceptions += (SkipTest,) if isinstance(collector, pytest.Generator): call_optional(collector.obj, 'setup') diff -r 1944bf94e4648184bddcb5bbbbe8c02bcecd2184 -r 8cf687dda7b0c121f14332244b44135bf0407752 _pytest/runner.py --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -249,7 +249,7 @@ if not call.excinfo: outcome = "passed" else: - if call.excinfo.errisinstance(py.test.skip.Exception): + if call.excinfo.errisinstance(collector.skip_exceptions): outcome = "skipped" r = collector._repr_failure_py(call.excinfo, "line").reprcrash longrepr = (str(r.path), r.lineno, r.message) diff -r 1944bf94e4648184bddcb5bbbbe8c02bcecd2184 -r 8cf687dda7b0c121f14332244b44135bf0407752 testing/test_nose.py --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -305,3 +305,12 @@ 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*") https://bitbucket.org/hpk42/pytest/commits/15d47614851b/ Changeset: 15d47614851b User: antocuni Date: 2013-03-14 16:53:57 Summary: (antocuni, ronny around): import directly from _pytest.runner to avoid the usage of @property Affected #: 1 file diff -r 8cf687dda7b0c121f14332244b44135bf0407752 -r 15d47614851bd72c4e7afc88f8fae5ae38d0fae9 _pytest/main.py --- a/_pytest/main.py +++ b/_pytest/main.py @@ -10,6 +10,7 @@ from UserDict import DictMixin as MappingMixin from _pytest.mark import MarkInfo +import _pytest.runner tracebackcutdir = py.path.local(_pytest.__file__).dirpath() @@ -348,16 +349,9 @@ 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 + # the set of exceptions to interpret as "Skip the whole module" during + # collection + skip_exceptions = (_pytest.runner.Skipped,) class CollectError(Exception): """ an error during collection, contains a custom message. """ https://bitbucket.org/hpk42/pytest/commits/2393d3dcacdf/ Changeset: 2393d3dcacdf User: hpk42 Date: 2013-08-16 11:33:58 Summary: merge pull request #27: correctly handle nose.SkipTest during collection. Thanks Antonio Cuni, Ronny Pfannschmidt. I did a few tweaks to the test and the activation (depending on if unittest is imported at all). Affected #: 6 files diff -r 6020045d40a9f50cf62019657a7b58caf6c80435 -r 2393d3dcacdf411a855acaac836bae027d72a668 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ Changes between 2.3.5 and 2.4.DEV ----------------------------------- +- PR27: correctly handle nose.SkipTest during collection. Thanks + Antonio Cuni, Ronny Pfannschmidt. + - new monkeypatch.replace() to avoid imports and provide a shorter invocation for patching out classes/functions from modules: diff -r 6020045d40a9f50cf62019657a7b58caf6c80435 -r 2393d3dcacdf411a855acaac836bae027d72a668 _pytest/main.py --- a/_pytest/main.py +++ b/_pytest/main.py @@ -10,6 +10,7 @@ from UserDict import DictMixin as MappingMixin from _pytest.mark import MarkInfo +import _pytest.runner tracebackcutdir = py.path.local(_pytest.__file__).dirpath() @@ -368,6 +369,11 @@ """ Collector instances create children through collect() and thus iteratively build a tree. """ + + # the set of exceptions to interpret as "Skip the whole module" during + # collection + skip_exceptions = (_pytest.runner.Skipped,) + class CollectError(Exception): """ an error during collection, contains a custom message. """ diff -r 6020045d40a9f50cf62019657a7b58caf6c80435 -r 2393d3dcacdf411a855acaac836bae027d72a668 _pytest/nose.py --- a/_pytest/nose.py +++ b/_pytest/nose.py @@ -40,6 +40,9 @@ # del item.parent._nosegensetup def pytest_make_collect_report(collector): + if sys.modules.get("unittest"): + SkipTest = py.std.unittest.SkipTest + collector.skip_exceptions += (SkipTest,) if isinstance(collector, pytest.Generator): call_optional(collector.obj, 'setup') diff -r 6020045d40a9f50cf62019657a7b58caf6c80435 -r 2393d3dcacdf411a855acaac836bae027d72a668 _pytest/pytester.py --- a/_pytest/pytester.py +++ b/_pytest/pytester.py @@ -604,9 +604,10 @@ passed = [] skipped = [] failed = [] - for rep in self.getreports("pytest_runtest_logreport"): + for rep in self.getreports( + "pytest_collectreport pytest_runtest_logreport"): if rep.passed: - if rep.when == "call": + if getattr(rep, "when", None) == "call": passed.append(rep) elif rep.skipped: skipped.append(rep) diff -r 6020045d40a9f50cf62019657a7b58caf6c80435 -r 2393d3dcacdf411a855acaac836bae027d72a668 _pytest/runner.py --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -258,7 +258,7 @@ if not call.excinfo: outcome = "passed" else: - if call.excinfo.errisinstance(py.test.skip.Exception): + if call.excinfo.errisinstance(collector.skip_exceptions): outcome = "skipped" r = collector._repr_failure_py(call.excinfo, "line").reprcrash longrepr = (str(r.path), r.lineno, r.message) diff -r 6020045d40a9f50cf62019657a7b58caf6c80435 -r 2393d3dcacdf411a855acaac836bae027d72a668 testing/test_nose.py --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -327,6 +327,15 @@ """Undoes the setup.""" raise Exception("should not call teardown for skipped tests") ''') + reprec = testdir.inline_run() + reprec.assertoutcome(passed=1, skipped=1) - result = testdir.runpytest() - result.stdout.fnmatch_lines("*1 skipped*") +def test_SkipTest_during_collection(testdir): + testdir.makepyfile(""" + import nose + raise nose.SkipTest("during collection") + def test_failing(): + assert False + """) + reprec = testdir.inline_run() + reprec.assertoutcome(skipped=1) Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org http://mail.python.org/mailman/listinfo/pytest-commit