testtools: Merge in new upstream.
[nivanova/samba-autobuild/.git] / lib / testtools / testtools / tests / test_run.py
index 508752730430a1a693cf950e98134c6237147455..8f88fb62ece7b0bec15a732058f1ca327284ed6a 100644 (file)
@@ -2,10 +2,9 @@
 
 """Tests for the test runner logic."""
 
-import StringIO
-
-from testtools.helpers import try_import
+from testtools.helpers import try_import, try_imports
 fixtures = try_import('fixtures')
+StringIO = try_imports(['StringIO.StringIO', 'io.StringIO'])
 
 import testtools
 from testtools import TestCase, run
@@ -43,7 +42,7 @@ class TestRun(TestCase):
         if fixtures is None:
             self.skipTest("Need fixtures")
         package = self.useFixture(SampleTestFixture())
-        out = StringIO.StringIO()
+        out = StringIO()
         run.main(['prog', '-l', 'testtools.runexample.test_suite'], out)
         self.assertEqual("""testtools.runexample.TestFoo.test_bar
 testtools.runexample.TestFoo.test_quux
@@ -53,7 +52,7 @@ testtools.runexample.TestFoo.test_quux
         if fixtures is None:
             self.skipTest("Need fixtures")
         package = self.useFixture(SampleTestFixture())
-        out = StringIO.StringIO()
+        out = StringIO()
         # We load two tests - one that exists and one that doesn't, and we
         # should get the one that exists and neither the one that doesn't nor
         # the unmentioned one that does.