Python version compatibility fixes.
authorThomi Richards <thomi.richards@canonical.com>
Sun, 24 Nov 2013 22:46:12 +0000 (11:46 +1300)
committerThomi Richards <thomi.richards@canonical.com>
Sun, 24 Nov 2013 22:46:12 +0000 (11:46 +1300)
python/subunit/tests/test_output_filter.py

index ba96687..658174c 100644 (file)
 #  license you chose for the specific language governing permissions and
 #  limitations under that license.
 #
-import optparse
 import datetime
 from functools import partial
 from io import BytesIO, StringIO
+import optparse
+import sys
 from tempfile import NamedTemporaryFile
 
 from testscenarios import WithScenarios
@@ -127,7 +128,10 @@ class ArgParserTests(TestCase):
     def setUp(self):
         super(ArgParserTests, self).setUp()
         # prevent OptionParser from printing to stderr:
-        self._stderr = BytesIO()
+        if sys.version[0] > '2':
+            self._stderr = StringIO()
+        else:
+            self._stderr = BytesIO()
         self.patch(optparse.sys, 'stderr', self._stderr)
 
     def test_can_parse_attach_file_without_test_id(self):