From e881f76a91df0b8124c4fda5ee31cd03f3318e44 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Tue, 6 May 2008 00:16:42 +1200 Subject: Use the test ID, not the test description. --- python/subunit/__init__.py | 8 ++++---- python/subunit/tests/test_test_protocol.py | 26 ++++++++++++-------------- 2 files changed, 16 insertions(+), 18 deletions(-) (limited to 'python') diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index f0b0987..5ee25d1 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -214,25 +214,25 @@ class TestProtocolClient(unittest.TestResult): def addError(self, test, error): """Report an error in test test.""" - self._stream.write("error: %s [\n" % test.shortDescription()) + self._stream.write("error: %s [\n" % test.id()) for line in self._exc_info_to_string(error, test).split(): self._stream.write("%s\n" % line) self._stream.write("]\n") def addFailure(self, test, error): """Report a failure in test test.""" - self._stream.write("failure: %s [\n" % test.shortDescription()) + self._stream.write("failure: %s [\n" % test.id()) for line in self._exc_info_to_string(error, test).split(): self._stream.write("%s\n" % line) self._stream.write("]\n") def addSuccess(self, test): """Report a success in a test.""" - self._stream.write("successful: %s\n" % test.shortDescription()) + self._stream.write("successful: %s\n" % test.id()) def startTest(self, test): """Mark a test as starting its test run.""" - self._stream.write("test: %s\n" % test.shortDescription()) + self._stream.write("test: %s\n" % test.id()) def RemoteError(description=""): diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 0083954..5fd8e36 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -694,8 +694,7 @@ class TestTestProtocolClient(unittest.TestCase): def test_start_test(self): """Test startTest on a TestProtocolClient.""" self.protocol.startTest(self.test) - self.assertEqual(self.io.getvalue(), "test: Test startTest on a " - "TestProtocolClient.\n") + self.assertEqual(self.io.getvalue(), "test: %s\n" % self.test.id()) def test_stop_test(self): """Test stopTest on a TestProtocolClient.""" @@ -705,26 +704,25 @@ class TestTestProtocolClient(unittest.TestCase): def test_add_success(self): """Test addSuccess on a TestProtocolClient.""" self.protocol.addSuccess(self.test) - self.assertEqual(self.io.getvalue(), "successful: Test startTest on a " - "TestProtocolClient.\n") + self.assertEqual( + self.io.getvalue(), "successful: %s\n" % self.test.id()) def test_add_failure(self): """Test addFailure on a TestProtocolClient.""" self.protocol.addFailure(self.test, subunit.RemoteError("boo")) - self.assertEqual(self.io.getvalue(), "failure: Test startTest on a " - "TestProtocolClient. [\n" - "RemoteException:\n" - "boo\n" - "]\n") + self.assertEqual( + self.io.getvalue(), + 'failure: %s [\nRemoteException:\nboo\n]\n' % self.test.id()) def test_add_error(self): """Test stopTest on a TestProtocolClient.""" self.protocol.addError(self.test, subunit.RemoteError("phwoar")) - self.assertEqual(self.io.getvalue(), "error: Test startTest on a " - "TestProtocolClient. [\n" - "RemoteException:\n" - "phwoar\n" - "]\n") + self.assertEqual( + self.io.getvalue(), + 'error: %s [\n' + "RemoteException:\n" + "phwoar\n" + "]\n" % self.test.id()) def test_suite(): -- cgit v1.2.1 From 150a47e415a72cf43b06b024faf8ea7aee0ab281 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Thu, 19 Jun 2008 10:55:24 +1000 Subject: Split tracebacks by *line* rather than by any whitespace. --- python/subunit/__init__.py | 4 ++-- python/subunit/tests/test_test_protocol.py | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'python') diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 5ee25d1..f52dbaa 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -215,14 +215,14 @@ class TestProtocolClient(unittest.TestResult): def addError(self, test, error): """Report an error in test test.""" self._stream.write("error: %s [\n" % test.id()) - for line in self._exc_info_to_string(error, test).split(): + for line in self._exc_info_to_string(error, test).splitlines(): self._stream.write("%s\n" % line) self._stream.write("]\n") def addFailure(self, test, error): """Report a failure in test test.""" self._stream.write("failure: %s [\n" % test.id()) - for line in self._exc_info_to_string(error, test).split(): + for line in self._exc_info_to_string(error, test).splitlines(): self._stream.write("%s\n" % line) self._stream.write("]\n") diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 5fd8e36..0b9fc77 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -709,19 +709,20 @@ class TestTestProtocolClient(unittest.TestCase): def test_add_failure(self): """Test addFailure on a TestProtocolClient.""" - self.protocol.addFailure(self.test, subunit.RemoteError("boo")) + self.protocol.addFailure( + self.test, subunit.RemoteError("boo qux")) self.assertEqual( self.io.getvalue(), - 'failure: %s [\nRemoteException:\nboo\n]\n' % self.test.id()) + 'failure: %s [\nRemoteException: boo qux\n]\n' % self.test.id()) def test_add_error(self): """Test stopTest on a TestProtocolClient.""" - self.protocol.addError(self.test, subunit.RemoteError("phwoar")) + self.protocol.addError( + self.test, subunit.RemoteError("phwoar crikey")) self.assertEqual( self.io.getvalue(), 'error: %s [\n' - "RemoteException:\n" - "phwoar\n" + "RemoteException: phwoar crikey\n" "]\n" % self.test.id()) -- cgit v1.2.1 From 0c09f4a34ac3d4f75292306839709bc18762f8ac Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sat, 13 Dec 2008 15:29:46 +1100 Subject: Review feedback from jml. --- python/subunit/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index bf1e0cc..b2b5129 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -1,5 +1,5 @@ # -# subunit: extensions to python unittest to get test results from subprocesses. +# subunit: extensions to Python unittest to get test results from subprocesses. # Copyright (C) 2005 Robert Collins # # This program is free software; you can redistribute it and/or modify @@ -220,7 +220,7 @@ class TestProtocolServer(object): class RemoteException(Exception): - """An exception that occured remotely to python.""" + """An exception that occured remotely to Python.""" def __eq__(self, other): try: @@ -268,7 +268,7 @@ def RemoteError(description=""): class RemotedTestCase(unittest.TestCase): """A class to represent test cases run in child processes. - Instances of this class are used to provide the python test API a TestCase + Instances of this class are used to provide the Python test API a TestCase that can be printed to the screen, introspected for metadata and so on. However, as they are a simply a memoisation of a test that was actually run in the past by a separate process, they cannot perform any interactive -- cgit v1.2.1