diff options
| author | Robert Collins <robertc@robertcollins.net> | 2009-10-24 20:28:19 +1100 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2009-10-24 20:28:19 +1100 |
| commit | b233594fc6031cc034e390387be187ae24c11e75 (patch) | |
| tree | 2f8dc1327c1a6311d5945b261bdb3c1540d9c306 /python | |
| parent | 2a9fac07e208637dcecf5d57fafa2b6bbbe0ef2c (diff) | |
| download | subunit-git-b233594fc6031cc034e390387be187ae24c11e75.tar.gz | |
Move expected failures to the details API.
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/__init__.py | 4 | ||||
| -rw-r--r-- | python/subunit/tests/test_test_protocol.py | 38 |
2 files changed, 34 insertions, 8 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 5c8585f..570af8b 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -276,7 +276,7 @@ class _InTest(_ParserState): def _xfail(self): self.parser.client.addExpectedFailure(self.parser._current_test, - RemoteError()) + details={}) def addExpectedFail(self, offset, line): """An 'xfail:' directive has been read.""" @@ -386,7 +386,7 @@ class _ReadingExpectedFailureDetails(_ReadingDetails): def _report_outcome(self): self.parser.client.addExpectedFailure(self.parser._current_test, - RemoteError(self.details_parser.get_message())) + details=self.details_parser.get_details()) def _outcome_label(self): return "xfail" diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index d117a40..1a4e1fd 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -474,10 +474,15 @@ class TestTestProtocolServerAddxFail(unittest.TestCase): self.setup_protocol() def setup_python27(self): - """Setup a test object ready to be xfailed and thunk to success.""" + """Setup a test object ready to be xfailed.""" self.client = Python27TestResult() self.setup_protocol() + def setup_python_ex(self): + """Setup a test object ready to be xfailed with details.""" + self.client = ExtendedTestResult() + self.setup_protocol() + def setup_protocol(self): """Setup the protocol based on self.client.""" self.protocol = subunit.TestProtocolServer(self.client) @@ -488,7 +493,7 @@ class TestTestProtocolServerAddxFail(unittest.TestCase): self.protocol.lineReceived("%s mcdonalds farm\n" % keyword) self.check_success_or_xfail(as_success) - def check_success_or_xfail(self, as_success, error_message=""): + def check_success_or_xfail(self, as_success, error_message=None): if as_success: self.assertEqual([ ('startTest', self.test), @@ -496,10 +501,21 @@ class TestTestProtocolServerAddxFail(unittest.TestCase): ('stopTest', self.test), ], self.client._calls) else: - error = subunit.RemoteError(error_message) + details = {} + if error_message is not None: + details['traceback'] = Content( + ContentType("text", "x-traceback"), lambda:[error_message]) + if isinstance(self.client, ExtendedTestResult): + value = details + else: + if error_message is not None: + value = subunit.RemoteError('Text attachment: traceback\n' + '------------\n' + error_message + '------------\n') + else: + value = subunit.RemoteError() self.assertEqual([ ('startTest', self.test), - ('addExpectedFailure', self.test, error), + ('addExpectedFailure', self.test, value), ('stopTest', self.test), ], self.client._calls) @@ -508,23 +524,29 @@ class TestTestProtocolServerAddxFail(unittest.TestCase): self.simple_xfail_keyword("xfail", True) self.setup_python27() self.simple_xfail_keyword("xfail", False) + self.setup_python_ex() + self.simple_xfail_keyword("xfail", False) def test_simple_xfail_colon(self): self.setup_python26() self.simple_xfail_keyword("xfail:", True) self.setup_python27() self.simple_xfail_keyword("xfail:", False) + self.setup_python_ex() + self.simple_xfail_keyword("xfail:", False) def test_xfail_empty_message(self): self.setup_python26() self.empty_message(True) self.setup_python27() self.empty_message(False) + self.setup_python_ex() + self.empty_message(False, error_message="") - def empty_message(self, as_success): + def empty_message(self, as_success, error_message="\n"): self.protocol.lineReceived("xfail mcdonalds farm [\n") self.protocol.lineReceived("]\n") - self.check_success_or_xfail(as_success) + self.check_success_or_xfail(as_success, error_message) def xfail_quoted_bracket(self, keyword, as_success): # This tests it is accepted, but cannot test it is used today, because @@ -539,12 +561,16 @@ class TestTestProtocolServerAddxFail(unittest.TestCase): self.xfail_quoted_bracket("xfail", True) self.setup_python27() self.xfail_quoted_bracket("xfail", False) + self.setup_python_ex() + self.xfail_quoted_bracket("xfail", False) def test_xfail_colon_quoted_bracket(self): self.setup_python26() self.xfail_quoted_bracket("xfail:", True) self.setup_python27() self.xfail_quoted_bracket("xfail:", False) + self.setup_python_ex() + self.xfail_quoted_bracket("xfail:", False) class TestTestProtocolServerAddSkip(unittest.TestCase): |
