summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomi Richards <thomi.richards@canonical.com>2013-12-02 19:12:14 +1300
committerThomi Richards <thomi.richards@canonical.com>2013-12-02 19:12:14 +1300
commit3763dba8d33291800236973791bc2d4d45b4a018 (patch)
treed531c7c1284b569a3249fd276ba60b61ad92262d
parent4aee3ea6c904afd4c98049552f6ac2fccb6d379d (diff)
downloadsubunit-3763dba8d33291800236973791bc2d4d45b4a018.tar.gz
Patch sys.stdin correctly for testing.
-rw-r--r--python/subunit/tests/test_output_filter.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py
index f53b37a..9a54a42 100644
--- a/python/subunit/tests/test_output_filter.py
+++ b/python/subunit/tests/test_output_filter.py
@@ -16,7 +16,7 @@
import datetime
from functools import partial
-from io import BytesIO, StringIO
+from io import BytesIO, StringIO, TextIOWrapper
import optparse
import sys
from tempfile import NamedTemporaryFile
@@ -108,12 +108,12 @@ class TestStatusArgParserTests(WithScenarios, TestCaseWithPatchedStderr):
self.assertThat(args.tags, Equals(["foo", "bar", "baz"]))
def test_attach_file_with_hyphen_opens_stdin(self):
- self.patch(_o.sys, 'stdin', StringIO(_u("Hello")))
+ self.patch(_o.sys, 'stdin', TextIOWrapper(BytesIO(b"Hello")))
args = safe_parse_arguments(
args=[self.option, "foo", "--attach-file", "-"]
)
- self.assertThat(args.attach_file.read(), Equals("Hello"))
+ self.assertThat(args.attach_file.read(), Equals(b"Hello"))
def test_attach_file_with_hyphen_sets_filename_to_stdin(self):
args = safe_parse_arguments(
@@ -311,7 +311,7 @@ class StatusStreamResultTests(WithScenarios, TestCase):
)
def test_can_read_stdin(self):
- self.patch(_o.sys, 'stdin', BytesIO(b"\xFE\xED\xFA\xCE"))
+ self.patch(_o.sys, 'stdin', TextIOWrapper(BytesIO(b"\xFE\xED\xFA\xCE")))
result = get_result_for([self.option, self.test_id, '--attach-file', '-'])
self.assertThat(