testtools-dev team mailing list archive
-
testtools-dev team
-
Mailing list archive
-
Message #00200
[Merge] lp:~jml/testtools/unexpected-success into lp:testtools
Jonathan Lange has proposed merging lp:~jml/testtools/unexpected-success into lp:testtools.
Requested reviews:
testtools developers (testtools-dev)
Related bugs:
#654474 An unexpectedSuccess is like a failure not a success
https://bugs.launchpad.net/bugs/654474
This branch makes addUnexpectedSuccess get translated to addFailure instead of addSuccess. This means we have to make up an actual failure to pass to addFailure. The way we do that, plus the way the tests are written are the two biggest uncertainties I have about this branch.
--
https://code.launchpad.net/~jml/testtools/unexpected-success/+merge/39220
Your team testtools developers is requested to review the proposed merge of lp:~jml/testtools/unexpected-success into lp:testtools.
=== modified file 'testtools/testresult/real.py'
--- testtools/testresult/real.py 2010-10-14 22:50:38 +0000
+++ testtools/testresult/real.py 2010-10-24 09:23:45 +0000
@@ -11,6 +11,7 @@
]
import datetime
+import sys
import unittest
from testtools.compat import _format_exc_info, str_is_unicode, _u
@@ -432,7 +433,10 @@
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)
=== modified file 'testtools/tests/test_testresult.py'
--- testtools/tests/test_testresult.py 2010-10-21 13:09:35 +0000
+++ testtools/tests/test_testresult.py 2010-10-24 09:23:45 +0000
@@ -810,7 +810,7 @@
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 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(
Follow ups