diff --git a/python/subunit/tests/test_test_protocol2.py b/python/subunit/tests/test_test_protocol2.py index 6d1e03b..2874e43 100644 --- a/python/subunit/tests/test_test_protocol2.py +++ b/python/subunit/tests/test_test_protocol2.py @@ -30,7 +30,12 @@ from testtools import TestCase from testtools.matchers import Contains, HasLength from testtools.testresult.doubles import StreamResult -from testtools.tests.test_testresult import TestStreamResultContract + +try: + from testtools.tests.test_testresult import TestStreamResultContract +except ImportError: + # testtools >= 2.8 no longer includes the tests submodule + TestStreamResultContract = None import subunit import iso8601 @@ -54,11 +59,13 @@ ] -class TestStreamResultToBytesContract(TestCase, TestStreamResultContract): - """Check that StreamResult behaves as testtools expects.""" +if TestStreamResultContract is not None: - def _make_result(self): - return subunit.StreamResultToBytes(BytesIO()) + class TestStreamResultToBytesContract(TestCase, TestStreamResultContract): + """Check that StreamResult behaves as testtools expects.""" + + def _make_result(self): + return subunit.StreamResultToBytes(BytesIO()) class TestStreamResultToBytes(TestCase):