diff options
| author | Robert Collins <robertc@robertcollins.net> | 2011-04-25 09:27:18 +1200 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2011-04-25 09:27:18 +1200 |
| commit | 03725c57337459b29a32927146146b874d3b3003 (patch) | |
| tree | 9a155d57960a7100a723ee10f754e1785d9be3b0 /python | |
| parent | 32b4cbe9c436a63ca330b30bbe41566d6335e637 (diff) | |
| parent | 93d8ed3ffed812c37cf54b4ccc22a25026f940ae (diff) | |
| download | subunit-git-03725c57337459b29a32927146146b874d3b3003.tar.gz | |
Fixup initial py3 support from tres and start digging further.
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/__init__.py | 22 | ||||
| -rw-r--r-- | python/subunit/details.py | 3 |
2 files changed, 12 insertions, 13 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 9dc849a..ba7f63e 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -118,13 +118,12 @@ Utility modules import os import re -from StringIO import StringIO import subprocess import sys import unittest -import iso8601 from testtools import content, content_type, ExtendedToOriginalDecorator +from testtools.compat import _b, _u, StringIO try: from testtools.testresult.real import _StringException RemoteException = _StringException @@ -134,7 +133,7 @@ except ImportError: "_StringException, check your version.") from testtools import testresult -import chunked, details, test_results +from subunit import chunked, details, iso8601, test_results PROGRESS_SET = 0 @@ -241,7 +240,7 @@ class _ParserState(object): def lostConnection(self): """Connection lost.""" - self.parser._lostConnectionInTest(u'unknown state of ') + self.parser._lostConnectionInTest(_u('unknown state of ')) def startTest(self, offset, line): """A test start command received.""" @@ -321,7 +320,7 @@ class _InTest(_ParserState): def lostConnection(self): """Connection lost.""" - self.parser._lostConnectionInTest(u'') + self.parser._lostConnectionInTest(_u('')) class _OutSideTest(_ParserState): @@ -356,7 +355,7 @@ class _ReadingDetails(_ParserState): def lostConnection(self): """Connection lost.""" - self.parser._lostConnectionInTest(u'%s report of ' % + self.parser._lostConnectionInTest(_u('%s report of ') % self._outcome_label()) def _outcome_label(self): @@ -489,8 +488,9 @@ class TestProtocolServer(object): # Accept it, but do not do anything with it yet. try: event_time = iso8601.parse_date(line[offset:-1]) - except TypeError, e: - raise TypeError("Failed to parse %r, got %r" % (line, e)) + except TypeError: + raise TypeError(_u("Failed to parse %r, got %r") + % (line, sys.exec_info[1])) self.client.time(event_time) def lineReceived(self, line): @@ -498,7 +498,7 @@ class TestProtocolServer(object): self._state.lineReceived(line) def _lostConnectionInTest(self, state_string): - error_string = u"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) @@ -710,7 +710,7 @@ class TestProtocolClient(testresult.TestResult): """Obey the testtools result.done() interface.""" -def RemoteError(description=u""): +def RemoteError(description=_u("")): return (_StringException, _StringException(description), None) @@ -760,7 +760,7 @@ class RemotedTestCase(unittest.TestCase): def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) - result.addError(self, RemoteError(u"Cannot run RemotedTestCases.\n")) + result.addError(self, RemoteError(_u("Cannot run RemotedTestCases.\n"))) result.stopTest(self) def _strclass(self): diff --git a/python/subunit/details.py b/python/subunit/details.py index a37b2ac..aedba9d 100644 --- a/python/subunit/details.py +++ b/python/subunit/details.py @@ -16,9 +16,8 @@ """Handlers for outcome details.""" -from cStringIO import StringIO - from testtools import content, content_type +from testtools.compat import StringIO import chunked |
