summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2015-07-13 17:55:22 +1200
committerRobert Collins <robertc@robertcollins.net>2015-07-13 17:55:22 +1200
commit2bd3a0ef34b3fee9b6608799be31844cc0510164 (patch)
treebba91060ca00f0f068b649179013b6fbb48a6487
parentf03111e5df11a6762438874ccb660a44771073fd (diff)
downloadsubunit-2bd3a0ef34b3fee9b6608799be31844cc0510164.tar.gz
Handle pypy, Python 3.4 and 3.5 in tests.
-rw-r--r--python/subunit/tests/__init__.py5
-rw-r--r--python/subunit/tests/test_test_protocol.py14
2 files changed, 10 insertions, 9 deletions
diff --git a/python/subunit/tests/__init__.py b/python/subunit/tests/__init__.py
index ae772e7..a62a006 100644
--- a/python/subunit/tests/__init__.py
+++ b/python/subunit/tests/__init__.py
@@ -22,10 +22,7 @@ from testscenarios import generate_scenarios
# Before the test module imports to avoid circularity.
# For testing: different pythons have different str() implementations.
-if (3,1) < sys.version_info < (3, 4):
- _remote_exception_repr = "testtools.testresult.real._StringException"
-else:
- _remote_exception_repr = "_StringException"
+_remote_exception_repr = "testtools.testresult.real._StringException"
_remote_exception_str = "Traceback (most recent call last):\ntesttools.testresult.real._StringException"
_remote_exception_str_chunked = "57\r\n" + _remote_exception_str + ": boo qux\n0\r\n"
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py
index c6008f4..f3cd0e3 100644
--- a/python/subunit/tests/test_test_protocol.py
+++ b/python/subunit/tests/test_test_protocol.py
@@ -15,7 +15,7 @@
#
import datetime
-import unittest
+import unittest2 as unittest
import os
from testtools import PlaceHolder, skipIf, TestCase, TestResult
@@ -45,6 +45,9 @@ from subunit.tests import (
import subunit.iso8601 as iso8601
+tb_prelude = "Traceback (most recent call last):\n"
+
+
def details_to_str(details):
return TestResult()._err_details_to_string(None, details=details)
@@ -108,11 +111,12 @@ class TestTestProtocolServerPipe(unittest.TestCase):
protocol.readFrom(pipe)
bing = subunit.RemotedTestCase("bing crosby")
an_error = subunit.RemotedTestCase("an error")
- self.assertEqual(client.errors,
- [(an_error, _remote_exception_repr + '\n')])
+ self.assertEqual(
+ client.errors,
+ [(an_error, tb_prelude + _remote_exception_repr + '\n')])
self.assertEqual(
client.failures,
- [(bing, _remote_exception_repr + ": "
+ [(bing, tb_prelude + _remote_exception_repr + ": "
+ details_to_str({'traceback': text_content(traceback)}) + "\n")])
self.assertEqual(client.testsRun, 3)
@@ -967,7 +971,7 @@ class TestRemotedTestCase(unittest.TestCase):
"'A test description'>", "%r" % test)
result = unittest.TestResult()
test.run(result)
- self.assertEqual([(test, _remote_exception_repr + ": "
+ self.assertEqual([(test, tb_prelude + _remote_exception_repr + ": "
"Cannot run RemotedTestCases.\n\n")],
result.errors)
self.assertEqual(1, result.testsRun)