Translate addUnexpectedSuccess to addFailure instead of addSuccess.

This commit is contained in:
Jonathan Lange
2010-10-24 10:21:01 +01:00
parent 80048a7cf1
commit 0a19b9385a
2 changed files with 36 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ __all__ = [
]
import datetime
import sys
import unittest
from testtools.compat import _format_exc_info, str_is_unicode, _u
@@ -432,7 +433,10 @@ class ExtendedToOriginalDecorator(object):
def addUnexpectedSuccess(self, test, details=None):
outcome = getattr(self.decorated, 'addUnexpectedSuccess', None)
if outcome is None:
return self.decorated.addSuccess(test)
try:
test.fail("")
except test.failureException:
return self.addFailure(test, sys.exc_info())
if details is not None:
try:
return outcome(test, details=details)

View File

@@ -810,7 +810,7 @@ class TestExtendedToOriginalAddSkip(
self.make_27_result()
self.check_outcome_details_to_string(self.outcome)
def test_outcome_Extended_py27_no_reason(self):
def test_outcome_Extended_py27_reason(self):
self.make_27_result()
self.check_outcome_details_to_arg(self.outcome, 'foo',
{'reason': Content(UTF8_TEXT, lambda:['foo'])})
@@ -857,9 +857,38 @@ class TestExtendedToOriginalAddSuccess(
class TestExtendedToOriginalAddUnexpectedSuccess(
TestExtendedToOriginalAddSuccess):
TestExtendedToOriginalResultDecoratorBase):
outcome = 'addUnexpectedSuccess'
expected = 'addFailure'
def test_outcome_Original_py26(self):
self.make_26_result()
getattr(self.converter, self.outcome)(self)
[event] = self.result._events
self.assertEqual((self.expected, self), event[:2])
def test_outcome_Original_py27(self):
self.make_27_result()
self.check_outcome_nothing(self.outcome)
def test_outcome_Original_pyextended(self):
self.make_extended_result()
self.check_outcome_nothing(self.outcome)
def test_outcome_Extended_py26(self):
self.make_26_result()
getattr(self.converter, self.outcome)(self)
[event] = self.result._events
self.assertEqual((self.expected, self), event[:2])
def test_outcome_Extended_py27(self):
self.make_27_result()
self.check_outcome_details_to_nothing(self.outcome)
def test_outcome_Extended_pyextended(self):
self.make_extended_result()
self.check_outcome_details(self.outcome)
class TestExtendedToOriginalResultOtherAttributes(