From 3763dba8d33291800236973791bc2d4d45b4a018 Mon Sep 17 00:00:00 2001 From: Thomi Richards Date: Mon, 2 Dec 2013 19:12:14 +1300 Subject: Patch sys.stdin correctly for testing. --- python/subunit/tests/test_output_filter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'python') 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( -- cgit v1.2.1