diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/__init__.py | 40 | ||||
| -rw-r--r-- | python/subunit/tests/test_test_protocol.py | 14 |
2 files changed, 21 insertions, 33 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index f171f78..1fc34ec 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -119,32 +119,20 @@ class TestProtocolServer(object): elif (self.state == TestProtocolServer.READING_FAILURE or self.state == TestProtocolServer.READING_ERROR): self._appendMessage(line) - elif line.startswith("test:"): - self._startTest(6, line) - elif line.startswith("testing:"): - self._startTest(9, line) - elif line.startswith("testing"): - self._startTest(8, line) - elif line.startswith("test"): - self._startTest(5, line) - elif line.startswith("error:"): - self._addError(7, line) - elif line.startswith("error"): - self._addError(6, line) - elif line.startswith("failure:"): - self._addFailure(9, line) - elif line.startswith("failure"): - self._addFailure(8, line) - elif line.startswith("successful:"): - self._addSuccess(12, line) - elif line.startswith("successful"): - self._addSuccess(11, line) - elif line.startswith("success:"): - self._addSuccess(9, line) - elif line.startswith("success"): - self._addSuccess(8, line) else: - self.stdOutLineReceived(line) + cmd, rest = line.split(None, 1) + offset = len(cmd) + 1 + cmd = cmd.strip(':') + if cmd in ('test', 'testing'): + self._startTest(offset, line) + elif cmd == 'error': + self._addError(offset, line) + elif cmd == 'failure': + self._addFailure(offset, line) + elif cmd in ('success', 'successful'): + self._addSuccess(offset, line) + else: + self.stdOutLineReceived(line) def lostConnection(self): """The input connection has finished.""" @@ -230,7 +218,7 @@ class TestProtocolClient(unittest.TestResult): def RemoteError(description=""): if description == "": description = "\n" - return (RemoteException("RemoteError:\n%s" % description), None, None) + return (RemoteException, RemoteException(description), None) class RemotedTestCase(unittest.TestCase): diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index eb77e68..a2b054b 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -138,10 +138,10 @@ class TestTestProtocolServerPipe(unittest.TestCase): bing = subunit.RemotedTestCase("bing crosby") an_error = subunit.RemotedTestCase("an error") self.assertEqual(client.errors, - [(an_error, 'RemoteError:\n\n\n')]) - self.assertEqual(client.failures, - [(bing, - "RemoteError:\nfoo.c:53:ERROR invalid state\n\n")]) + [(an_error, 'RemoteException: \n\n')]) + self.assertEqual( + client.failures, + [(bing, "RemoteException: foo.c:53:ERROR invalid state\n\n")]) self.assertEqual(client.testsRun, 3) @@ -531,7 +531,7 @@ class TestRemotedTestCase(unittest.TestCase): "'A test description'>", "%r" % test) result = unittest.TestResult() test.run(result) - self.assertEqual([(test, "RemoteError:\n" + self.assertEqual([(test, "RemoteException: " "Cannot run RemotedTestCases.\n\n")], result.errors) self.assertEqual(1, result.testsRun) @@ -702,7 +702,7 @@ class TestTestProtocolClient(unittest.TestCase): self.protocol.addFailure(self.test, subunit.RemoteError("boo")) self.assertEqual(self.io.getvalue(), "failure: Test startTest on a " "TestProtocolClient. [\n" - "RemoteError:\n" + "RemoteException:\n" "boo\n" "]\n") @@ -711,7 +711,7 @@ class TestTestProtocolClient(unittest.TestCase): self.protocol.addError(self.test, subunit.RemoteError("phwoar")) self.assertEqual(self.io.getvalue(), "error: Test startTest on a " "TestProtocolClient. [\n" - "RemoteError:\n" + "RemoteException:\n" "phwoar\n" "]\n") |
