Fix make check with testtools trunk.
authorRobert Collins <robertc@robertcollins.net>
Thu, 24 Jun 2010 10:02:35 +0000 (20:02 +1000)
committerRobert Collins <robertc@robertcollins.net>
Thu, 24 Jun 2010 10:02:35 +0000 (20:02 +1000)
NEWS
python/subunit/__init__.py
python/subunit/tests/test_test_protocol.py

diff --git a/NEWS b/NEWS
index fcdd634..c6b4451 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ NEXT (In development)
 BUG FIXES
 ~~~~~~~~~
 
 BUG FIXES
 ~~~~~~~~~
 
+* Be consistent about delivering unicode content to testtools StringException
+  class which has become (appropriately) conservative. (Robert Collins)
+
 * Fix incorrect reference to subunit_test_failf in c/README.
   (Brad Hards, #524341)
 
 * Fix incorrect reference to subunit_test_failf in c/README.
   (Brad Hards, #524341)
 
index 7734852..8d6da1e 100644 (file)
@@ -244,7 +244,7 @@ class _ParserState(object):
 
     def lostConnection(self):
         """Connection lost."""
 
     def lostConnection(self):
         """Connection lost."""
-        self.parser._lostConnectionInTest('unknown state of ')
+        self.parser._lostConnectionInTest(u'unknown state of ')
 
     def startTest(self, offset, line):
         """A test start command received."""
 
     def startTest(self, offset, line):
         """A test start command received."""
@@ -324,7 +324,7 @@ class _InTest(_ParserState):
 
     def lostConnection(self):
         """Connection lost."""
 
     def lostConnection(self):
         """Connection lost."""
-        self.parser._lostConnectionInTest('')
+        self.parser._lostConnectionInTest(u'')
 
 
 class _OutSideTest(_ParserState):
 
 
 class _OutSideTest(_ParserState):
@@ -359,7 +359,7 @@ class _ReadingDetails(_ParserState):
 
     def lostConnection(self):
         """Connection lost."""
 
     def lostConnection(self):
         """Connection lost."""
-        self.parser._lostConnectionInTest('%s report of ' %
+        self.parser._lostConnectionInTest(u'%s report of ' %
             self._outcome_label())
 
     def _outcome_label(self):
             self._outcome_label())
 
     def _outcome_label(self):
@@ -501,7 +501,7 @@ class TestProtocolServer(object):
         self._state.lineReceived(line)
 
     def _lostConnectionInTest(self, state_string):
         self._state.lineReceived(line)
 
     def _lostConnectionInTest(self, state_string):
-        error_string = "lost connection during %stest '%s'" % (
+        error_string = u"lost connection during %stest '%s'" % (
             state_string, self.current_test_description)
         self.client.addError(self._current_test, RemoteError(error_string))
         self.client.stopTest(self._current_test)
             state_string, self.current_test_description)
         self.client.addError(self._current_test, RemoteError(error_string))
         self.client.stopTest(self._current_test)
@@ -707,7 +707,7 @@ class TestProtocolClient(unittest.TestResult):
         """Obey the testtools result.done() interface."""
 
 
         """Obey the testtools result.done() interface."""
 
 
-def RemoteError(description=""):
+def RemoteError(description=u""):
     return (_StringException, _StringException(description), None)
 
 
     return (_StringException, _StringException(description), None)
 
 
@@ -757,7 +757,7 @@ class RemotedTestCase(unittest.TestCase):
     def run(self, result=None):
         if result is None: result = self.defaultTestResult()
         result.startTest(self)
     def run(self, result=None):
         if result is None: result = self.defaultTestResult()
         result.startTest(self)
-        result.addError(self, RemoteError("Cannot run RemotedTestCases.\n"))
+        result.addError(self, RemoteError(u"Cannot run RemotedTestCases.\n"))
         result.stopTest(self)
 
     def _strclass(self):
         result.stopTest(self)
 
     def _strclass(self):
index ea4a447..e1287b6 100644 (file)
@@ -289,7 +289,7 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
         self.protocol.lineReceived("test old mcdonald\n")
         self.protocol.lostConnection()
         failure = subunit.RemoteError(
         self.protocol.lineReceived("test old mcdonald\n")
         self.protocol.lostConnection()
         failure = subunit.RemoteError(
-            "lost connection during test 'old mcdonald'")
+            u"lost connection during test 'old mcdonald'")
         self.assertEqual([
             ('startTest', self.test),
             ('addError', self.test, failure),
         self.assertEqual([
             ('startTest', self.test),
             ('addError', self.test, failure),
@@ -302,7 +302,7 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
         self.protocol.lostConnection()
         self.assertEqual([
             ('startTest', self.test),
         self.protocol.lostConnection()
         self.assertEqual([
             ('startTest', self.test),
-            ('addError', self.test, subunit.RemoteError("")),
+            ('addError', self.test, subunit.RemoteError(u"")),
             ('stopTest', self.test),
             ], self.client._events)
 
             ('stopTest', self.test),
             ], self.client._events)
 
@@ -311,7 +311,7 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
         self.protocol.lineReceived("%s old mcdonald %s" % (outcome, opening))
         self.protocol.lostConnection()
         failure = subunit.RemoteError(
         self.protocol.lineReceived("%s old mcdonald %s" % (outcome, opening))
         self.protocol.lostConnection()
         failure = subunit.RemoteError(
-            "lost connection during %s report of test 'old mcdonald'" % 
+            u"lost connection during %s report of test 'old mcdonald'" % 
             outcome)
         self.assertEqual([
             ('startTest', self.test),
             outcome)
         self.assertEqual([
             ('startTest', self.test),
@@ -331,7 +331,7 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
         self.protocol.lostConnection()
         self.assertEqual([
             ('startTest', self.test),
         self.protocol.lostConnection()
         self.assertEqual([
             ('startTest', self.test),
-            ('addFailure', self.test, subunit.RemoteError("")),
+            ('addFailure', self.test, subunit.RemoteError(u"")),
             ('stopTest', self.test),
             ], self.client._events)
 
             ('stopTest', self.test),
             ], self.client._events)
 
@@ -545,7 +545,7 @@ class TestTestProtocolServerAddxFail(unittest.TestCase):
                 value = details
             else:
                 if error_message is not None:
                 value = details
             else:
                 if error_message is not None:
-                    value = subunit.RemoteError('Text attachment: traceback\n'
+                    value = subunit.RemoteError(u'Text attachment: traceback\n'
                         '------------\n' + error_message + '------------\n')
                 else:
                     value = subunit.RemoteError()
                         '------------\n' + error_message + '------------\n')
                 else:
                     value = subunit.RemoteError()
@@ -850,15 +850,15 @@ class TestRemotedTestCase(unittest.TestCase):
 class TestRemoteError(unittest.TestCase):
 
     def test_eq(self):
 class TestRemoteError(unittest.TestCase):
 
     def test_eq(self):
-        error = subunit.RemoteError("Something went wrong")
-        another_error = subunit.RemoteError("Something went wrong")
-        different_error = subunit.RemoteError("boo!")
+        error = subunit.RemoteError(u"Something went wrong")
+        another_error = subunit.RemoteError(u"Something went wrong")
+        different_error = subunit.RemoteError(u"boo!")
         self.assertEqual(error, another_error)
         self.assertNotEqual(error, different_error)
         self.assertNotEqual(different_error, another_error)
 
     def test_empty_constructor(self):
         self.assertEqual(error, another_error)
         self.assertNotEqual(error, different_error)
         self.assertNotEqual(different_error, another_error)
 
     def test_empty_constructor(self):
-        self.assertEqual(subunit.RemoteError(), subunit.RemoteError(""))
+        self.assertEqual(subunit.RemoteError(), subunit.RemoteError(u""))
 
 
 class TestExecTestCase(unittest.TestCase):
 
 
 class TestExecTestCase(unittest.TestCase):
@@ -1009,7 +1009,7 @@ class TestTestProtocolClient(unittest.TestCase):
             ContentType('text', 'plain'), lambda:['serialised\nform'])}
         self.sample_tb_details = dict(self.sample_details)
         self.sample_tb_details['traceback'] = TracebackContent(
             ContentType('text', 'plain'), lambda:['serialised\nform'])}
         self.sample_tb_details = dict(self.sample_details)
         self.sample_tb_details['traceback'] = TracebackContent(
-            subunit.RemoteError("boo qux"), self.test)
+            subunit.RemoteError(u"boo qux"), self.test)
 
     def test_start_test(self):
         """Test startTest on a TestProtocolClient."""
 
     def test_start_test(self):
         """Test startTest on a TestProtocolClient."""
@@ -1039,7 +1039,7 @@ class TestTestProtocolClient(unittest.TestCase):
     def test_add_failure(self):
         """Test addFailure on a TestProtocolClient."""
         self.protocol.addFailure(
     def test_add_failure(self):
         """Test addFailure on a TestProtocolClient."""
         self.protocol.addFailure(
-            self.test, subunit.RemoteError("boo qux"))
+            self.test, subunit.RemoteError(u"boo qux"))
         self.assertEqual(
             self.io.getvalue(),
             ('failure: %s [\n' + _remote_exception_str + ': boo qux\n]\n')
         self.assertEqual(
             self.io.getvalue(),
             ('failure: %s [\n' + _remote_exception_str + ': boo qux\n]\n')
@@ -1063,7 +1063,7 @@ class TestTestProtocolClient(unittest.TestCase):
     def test_add_error(self):
         """Test stopTest on a TestProtocolClient."""
         self.protocol.addError(
     def test_add_error(self):
         """Test stopTest on a TestProtocolClient."""
         self.protocol.addError(
-            self.test, subunit.RemoteError("phwoar crikey"))
+            self.test, subunit.RemoteError(u"phwoar crikey"))
         self.assertEqual(
             self.io.getvalue(),
             ('error: %s [\n' +
         self.assertEqual(
             self.io.getvalue(),
             ('error: %s [\n' +
@@ -1088,7 +1088,7 @@ class TestTestProtocolClient(unittest.TestCase):
     def test_add_expected_failure(self):
         """Test addExpectedFailure on a TestProtocolClient."""
         self.protocol.addExpectedFailure(
     def test_add_expected_failure(self):
         """Test addExpectedFailure on a TestProtocolClient."""
         self.protocol.addExpectedFailure(
-            self.test, subunit.RemoteError("phwoar crikey"))
+            self.test, subunit.RemoteError(u"phwoar crikey"))
         self.assertEqual(
             self.io.getvalue(),
             ('xfail: %s [\n' +
         self.assertEqual(
             self.io.getvalue(),
             ('xfail: %s [\n' +