summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomi Richards <thomi.richards@canonical.com>2013-11-25 18:30:14 +1300
committerThomi Richards <thomi.richards@canonical.com>2013-11-25 18:30:14 +1300
commit8ee031da94894c8249ba79a5f20442def5944699 (patch)
treefe1189816897540946ff4bc8f160bf2f71abf300
parentb1ca3bcbc0ce150d99b94d9c4b84de1b73693cb9 (diff)
downloadsubunit-8ee031da94894c8249ba79a5f20442def5944699.tar.gz
Add tests around reading binary files, empty files, and stdin.
-rw-r--r--python/subunit/tests/test_output_filter.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py
index a31ae2b..758110e 100644
--- a/python/subunit/tests/test_output_filter.py
+++ b/python/subunit/tests/test_output_filter.py
@@ -288,6 +288,39 @@ class StatusStreamResultTests(WithScenarios, TestCase):
])
)
+ def test_can_read_binary_files(self):
+ with temp_file_contents(b"\xDE\xAD\xBE\xEF") as f:
+ result = get_result_for([self.option, self.test_id, '--attach-file', f.name])
+
+ self.assertThat(
+ result._events,
+ MatchesListwise([
+ MatchesStatusCall(file_bytes=b"\xDE\xAD\xBE\xEF", eof=True),
+ ])
+ )
+
+ def test_can_read_empty_files(self):
+ with temp_file_contents(b"") as f:
+ result = get_result_for([self.option, self.test_id, '--attach-file', f.name])
+
+ self.assertThat(
+ result._events,
+ MatchesListwise([
+ MatchesStatusCall(file_bytes=b"", file_name=f.name, eof=True),
+ ])
+ )
+
+ def test_can_read_stdin(self):
+ self.patch(_o.sys, 'stdin', BytesIO(b"\xFE\xED\xFA\xCE"))
+ result = get_result_for([self.option, self.test_id, '--attach-file', '-'])
+
+ self.assertThat(
+ result._events,
+ MatchesListwise([
+ MatchesStatusCall(file_bytes=b"\xFE\xED\xFA\xCE", file_name='stdin', eof=True),
+ ])
+ )
+
def test_file_is_sent_with_test_id(self):
with temp_file_contents(b"Hello") as f:
result = get_result_for([self.option, self.test_id, '--attach-file', f.name])