Skip to content

Commit

Permalink
Implement support for unittest.expectedFailure
Browse files Browse the repository at this point in the history
Fixes issue nose-devs#33
  • Loading branch information
csdev committed Jan 3, 2015
1 parent e2b1749 commit d119716
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nose/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions unit_tests/test_result_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -51,13 +52,16 @@ 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)
proxy.afterTest(test)
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"
Expand Down

0 comments on commit d119716

Please sign in to comment.