diff options
| author | Robert Collins <robertc@robertcollins.net> | 2009-10-08 23:23:07 +1100 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2009-10-08 23:23:07 +1100 |
| commit | 1af90d7941a17338fc9a296ec5dce7ab79ade550 (patch) | |
| tree | 905865b9a4c02c72df7d7c71d45889444adc73ba /python | |
| parent | 446d6f69537d2fb2bff212e3f8ebc3f36b525740 (diff) | |
| download | subunit-git-1af90d7941a17338fc9a296ec5dce7ab79ade550.tar.gz | |
Wire up addSkip to details.
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/__init__.py | 19 | ||||
| -rw-r--r-- | python/subunit/tests/test_test_protocol.py | 14 |
2 files changed, 26 insertions, 7 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 1c6937c..a63a433 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -46,9 +46,9 @@ will either lose fidelity (for instance, folding expected failures to success in Python versions < 2.7 or 3.1), or discard the extended data (for extra details, tags, timestamping and progress markers). -The test outcome methods ``addSuccess``, ``addError``, ``addFailure`` take an -optional keyword parameter ``details`` which can be used instead of the usual -python unittest parameter. +The test outcome methods ``addSuccess``, ``addError``, ``addFailure``, +``addSkip`` take an optional keyword parameter ``details`` which can be used +instead of the usual python unittest parameter. When used the value of details should be a dict from ``string`` to ``subunit.content.Content`` objects. This is a draft API being worked on with the Python Testing In Python mail list, with the goal of permitting a common @@ -119,6 +119,8 @@ import unittest import iso8601 +import content, content_type + PROGRESS_SET = 0 PROGRESS_CUR = 1 @@ -529,11 +531,14 @@ class TestProtocolClient(unittest.TestResult): self._write_details(details) self._stream.write("]\n") - def addSkip(self, test, reason): + def addSkip(self, test, reason=None, details=None): """Report a skipped test.""" - self._stream.write("skip: %s [\n" % test.id()) - self._stream.write("%s\n" % reason) - self._stream.write("]\n") + if reason is None: + self._addOutcome("skip", test, error=None, details=details) + else: + self._stream.write("skip: %s [\n" % test.id()) + self._stream.write("%s\n" % reason) + self._stream.write("]\n") def addSuccess(self, test, details=None): """Report a success in a test.""" diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 1700de6..4434710 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -1140,6 +1140,20 @@ class TestTestProtocolClient(unittest.TestCase): self.assertEqual( self.io.getvalue(), 'skip: %s [\nHas it really?\n]\n' % self.test.id()) + + def test_add_skip_details(self): + """Test addSkip on a TestProtocolClient with details.""" + details = {'reason':Content( + ContentType('text', 'plain'), lambda:['Has it really?'])} + self.protocol.addSkip( + self.test, details=details) + self.assertEqual( + self.io.getvalue(), + "skip: %s [ multipart\n" + "Content-Type: text/plain\n" + "reason\n" + "14\nHas it really?0\n" + "]\n" % self.test.id()) def test_progress_set(self): self.protocol.progress(23, subunit.PROGRESS_SET) |
