diff --git a/nose/proxy.py b/nose/proxy.py index c2676cb1..b202264b 100644 --- a/nose/proxy.py +++ b/nose/proxy.py @@ -159,6 +159,17 @@ def addSkip(self, test, reason): plugins.addError(self.test, (SkipTest, reason, None)) self.result.addSkip(self.test, reason) + def addExpectedFailure(self, test, err): + self.assertMyTest(test) + self.result.addExpectedFailure(self.test, self._prepareErr(err)) + + def addUnexpectedSuccess(self, test): + self.assertMyTest(test) + self.test.passed = False + self.result.addUnexpectedSuccess(self.test) + if self.config.stopOnError: + self.shouldStop = True + def addSuccess(self, test): self.assertMyTest(test) self.plugins.addSuccess(self.test) diff --git a/unit_tests/test_result_proxy.py b/unit_tests/test_result_proxy.py index 3d6e2acb..9c4b9a65 100644 --- a/unit_tests/test_result_proxy.py +++ b/unit_tests/test_result_proxy.py @@ -12,6 +12,7 @@ def test_proxy_has_basic_methods(self): proxy = ResultProxy(res, test=None) methods = [ 'addError', 'addFailure', 'addSuccess', + 'addExpectedFailure', 'addUnexpectedSuccess', 'startTest', 'stopTest', 'stop' ] for method in methods: m = getattr(proxy, method) @@ -51,6 +52,8 @@ def runTest(self): proxy.addError(test, err) proxy.addFailure(test, err) proxy.addSuccess(test) + proxy.addExpectedFailure(test, err) + proxy.addUnexpectedSuccess(test) proxy.startTest(test) proxy.stopTest(test) proxy.beforeTest(test) @@ -58,6 +61,7 @@ def runTest(self): proxy.stop() proxy.shouldStop = 'yes please' for method in ['addError', 'addFailure', 'addSuccess', + 'addExpectedFailure', 'addUnexpectedSuccess', 'startTest', 'stopTest', 'beforeTest', 'afterTest', 'stop']: assert method in res.called, "%s was not proxied"