1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/05c01a1dd99d/ Changeset: 05c01a1dd99d User: RonnyPfannschmidt Date: 2013-03-25 10:52:02 Summary: fix Issue 265 - integrate nose setup/teardown with setupstate
as sideeffect teardown is only called if setup doesnt fail Affected #: 3 files diff -r aed3e1770a969fc8cd43e8d5a4a1a90e9bb2058a -r 05c01a1dd99d958629c15cc579f273bd738045c3 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ Changes between 2.3.4 and 2.3.5dev ----------------------------------- +- Issue 265 - integrate nose setup/teardown with setupstate + so it doesnt try to teardown if it did not setup + - issue 271 - dont write junitxml on slave nodes - Issue 274 - dont try to show full doctest example diff -r aed3e1770a969fc8cd43e8d5a4a1a90e9bb2058a -r 05c01a1dd99d958629c15cc579f273bd738045c3 _pytest/nose.py --- a/_pytest/nose.py +++ b/_pytest/nose.py @@ -28,8 +28,10 @@ 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 + item.session._setupstate.addfinalizer((lambda: teardown_nose(item)), item) -def pytest_runtest_teardown(item): +def teardown_nose(item): if is_potential_nosetest(item): if not call_optional(item.obj, 'teardown'): call_optional(item.parent.obj, 'teardown') diff -r aed3e1770a969fc8cd43e8d5a4a1a90e9bb2058a -r 05c01a1dd99d958629c15cc579f273bd738045c3 testing/test_nose.py --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -304,4 +304,27 @@ result = testdir.runpytest() result.stdout.fnmatch_lines("*1 passed*") +def test_setup_teardown_linking_issue265(testdir): + # we accidnetially didnt integrate nose setupstate with normal setupstate + # this test ensures that won't happen again + testdir.makepyfile(''' + import pytest + class TestGeneric(object): + def test_nothing(self): + """Tests the API of the implementation (for generic and specialized).""" + + @pytest.mark.skipif("True", reason="Skip tests to check if teardown is skipped as well.") + class TestSkipTeardown(TestGeneric): + + def setup(self): + """Sets up my specialized implementation for $COOL_PLATFORM.""" + raise Exception("should not call setup for skipped tests") + + def teardown(self): + """Undoes the setup.""" + raise Exception("should not call teardown for skipped tests") + ''') + + result = testdir.runpytest() + result.stdout.fnmatch_lines("*1 skipped*") 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