Make test suite importable in py3.
This commit is contained in:
@@ -53,7 +53,7 @@ def visitTests(suite, visitor):
|
||||
visitor.visitSuite(test)
|
||||
visitTests(test, visitor)
|
||||
else:
|
||||
print "unvisitable non-unittest.TestCase element %r (%r)" % (test, test.__class__)
|
||||
print ("unvisitable non-unittest.TestCase element %r (%r)" % (test, test.__class__))
|
||||
|
||||
|
||||
class TestSuite(unittest.TestSuite):
|
||||
|
@@ -15,9 +15,10 @@
|
||||
# limitations under that license.
|
||||
#
|
||||
|
||||
from cStringIO import StringIO
|
||||
import unittest
|
||||
|
||||
from testtools.compat import StringIO
|
||||
|
||||
import subunit.chunked
|
||||
|
||||
|
||||
|
@@ -14,9 +14,10 @@
|
||||
# limitations under that license.
|
||||
#
|
||||
|
||||
from cStringIO import StringIO
|
||||
import unittest
|
||||
|
||||
from testtools.compat import StringIO
|
||||
|
||||
import subunit.tests
|
||||
from subunit import content, content_type, details
|
||||
|
||||
|
@@ -19,9 +19,9 @@
|
||||
from datetime import datetime
|
||||
from subunit import iso8601
|
||||
import unittest
|
||||
from StringIO import StringIO
|
||||
|
||||
from testtools import TestCase
|
||||
from testtools.compat import StringIO
|
||||
from testtools.testresult.doubles import ExtendedTestResult
|
||||
|
||||
import subunit
|
||||
|
@@ -17,7 +17,8 @@
|
||||
"""Tests for subunit.TestResultStats."""
|
||||
|
||||
import unittest
|
||||
from StringIO import StringIO
|
||||
|
||||
from testtools.compat import StringIO
|
||||
|
||||
import subunit
|
||||
|
||||
|
@@ -17,7 +17,8 @@
|
||||
"""Tests for subunit.tag_stream."""
|
||||
|
||||
import unittest
|
||||
from StringIO import StringIO
|
||||
|
||||
from testtools.compat import StringIO
|
||||
|
||||
import subunit
|
||||
import subunit.test_results
|
||||
|
@@ -17,7 +17,9 @@
|
||||
"""Tests for TAP2SubUnit."""
|
||||
|
||||
import unittest
|
||||
from StringIO import StringIO
|
||||
|
||||
from testtools.compat import StringIO
|
||||
|
||||
import subunit
|
||||
|
||||
|
||||
|
@@ -16,9 +16,9 @@
|
||||
|
||||
import datetime
|
||||
import unittest
|
||||
from StringIO import StringIO
|
||||
import os
|
||||
|
||||
from testtools.compat import _u, StringIO
|
||||
from testtools.content import Content, TracebackContent
|
||||
from testtools.content_type import ContentType
|
||||
from testtools.tests.helpers import (
|
||||
@@ -286,7 +286,7 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
|
||||
self.protocol.lineReceived("test old mcdonald\n")
|
||||
self.protocol.lostConnection()
|
||||
failure = subunit.RemoteError(
|
||||
u"lost connection during test 'old mcdonald'")
|
||||
_u("lost connection during test 'old mcdonald'"))
|
||||
self.assertEqual([
|
||||
('startTest', self.test),
|
||||
('addError', self.test, failure),
|
||||
@@ -299,7 +299,7 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
|
||||
self.protocol.lostConnection()
|
||||
self.assertEqual([
|
||||
('startTest', self.test),
|
||||
('addError', self.test, subunit.RemoteError(u"")),
|
||||
('addError', self.test, subunit.RemoteError(_u(""))),
|
||||
('stopTest', self.test),
|
||||
], self.client._events)
|
||||
|
||||
@@ -308,7 +308,7 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
|
||||
self.protocol.lineReceived("%s old mcdonald %s" % (outcome, opening))
|
||||
self.protocol.lostConnection()
|
||||
failure = subunit.RemoteError(
|
||||
u"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),
|
||||
@@ -328,7 +328,7 @@ class TestTestProtocolServerLostConnection(unittest.TestCase):
|
||||
self.protocol.lostConnection()
|
||||
self.assertEqual([
|
||||
('startTest', self.test),
|
||||
('addFailure', self.test, subunit.RemoteError(u"")),
|
||||
('addFailure', self.test, subunit.RemoteError(_u(""))),
|
||||
('stopTest', self.test),
|
||||
], self.client._events)
|
||||
|
||||
@@ -542,8 +542,8 @@ class TestTestProtocolServerAddxFail(unittest.TestCase):
|
||||
value = details
|
||||
else:
|
||||
if error_message is not None:
|
||||
value = subunit.RemoteError(u'Text attachment: traceback\n'
|
||||
'------------\n' + error_message + '------------\n')
|
||||
value = subunit.RemoteError(_u("Text attachment: traceback\n"
|
||||
"------------\n") + error_message + _u("------------\n"))
|
||||
else:
|
||||
value = subunit.RemoteError()
|
||||
self.assertEqual([
|
||||
@@ -841,15 +841,15 @@ class TestRemotedTestCase(unittest.TestCase):
|
||||
class TestRemoteError(unittest.TestCase):
|
||||
|
||||
def test_eq(self):
|
||||
error = subunit.RemoteError(u"Something went wrong")
|
||||
another_error = subunit.RemoteError(u"Something went wrong")
|
||||
different_error = subunit.RemoteError(u"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(subunit.RemoteError(), subunit.RemoteError(u""))
|
||||
self.assertEqual(subunit.RemoteError(), subunit.RemoteError(_u("")))
|
||||
|
||||
|
||||
class TestExecTestCase(unittest.TestCase):
|
||||
@@ -1000,7 +1000,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(
|
||||
subunit.RemoteError(u"boo qux"), self.test)
|
||||
subunit.RemoteError(_u("boo qux")), self.test)
|
||||
|
||||
def test_start_test(self):
|
||||
"""Test startTest on a TestProtocolClient."""
|
||||
@@ -1030,7 +1030,7 @@ class TestTestProtocolClient(unittest.TestCase):
|
||||
def test_add_failure(self):
|
||||
"""Test addFailure on a TestProtocolClient."""
|
||||
self.protocol.addFailure(
|
||||
self.test, subunit.RemoteError(u"boo qux"))
|
||||
self.test, subunit.RemoteError(_u("boo qux")))
|
||||
self.assertEqual(
|
||||
self.io.getvalue(),
|
||||
('failure: %s [\n' + _remote_exception_str + ': boo qux\n]\n')
|
||||
@@ -1054,7 +1054,7 @@ class TestTestProtocolClient(unittest.TestCase):
|
||||
def test_add_error(self):
|
||||
"""Test stopTest on a TestProtocolClient."""
|
||||
self.protocol.addError(
|
||||
self.test, subunit.RemoteError(u"phwoar crikey"))
|
||||
self.test, subunit.RemoteError(_u("phwoar crikey")))
|
||||
self.assertEqual(
|
||||
self.io.getvalue(),
|
||||
('error: %s [\n' +
|
||||
@@ -1079,7 +1079,7 @@ class TestTestProtocolClient(unittest.TestCase):
|
||||
def test_add_expected_failure(self):
|
||||
"""Test addExpectedFailure on a TestProtocolClient."""
|
||||
self.protocol.addExpectedFailure(
|
||||
self.test, subunit.RemoteError(u"phwoar crikey"))
|
||||
self.test, subunit.RemoteError(_u("phwoar crikey")))
|
||||
self.assertEqual(
|
||||
self.io.getvalue(),
|
||||
('xfail: %s [\n' +
|
||||
|
Reference in New Issue
Block a user