From cacd5f6bc6eed91f25434517eac0db75ef8fb1ac Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sun, 2 Aug 2015 16:18:58 +1200 Subject: Handle very short packets Yay quickcheck. --- python/subunit/tests/test_test_protocol2.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'python/subunit/tests') diff --git a/python/subunit/tests/test_test_protocol2.py b/python/subunit/tests/test_test_protocol2.py index c21392c..9a84a84 100644 --- a/python/subunit/tests/test_test_protocol2.py +++ b/python/subunit/tests/test_test_protocol2.py @@ -17,6 +17,11 @@ from io import BytesIO import datetime +from hypothesis import given +# To debug hypothesis +# from hypothesis import Settings, Verbosity +# Settings.default.verbosity = Verbosity.verbose +import hypothesis.strategies as st from testtools import TestCase from testtools.matchers import Contains, HasLength from testtools.tests.test_testresult import TestStreamResultContract @@ -434,3 +439,12 @@ class TestByteStreamToStreamResult(TestCase): file_bytes=b'foo') self.check_event(content.getvalue(), test_id=None, file_name='bar', route_code='0', mime_type='text/plain', file_bytes=b'foo') + + @given(st.binary()) + def test_hypothesis_decoding(self, code_bytes): + source = BytesIO(code_bytes) + result = StreamResult() + stream = subunit.ByteStreamToStreamResult( + source, non_subunit_name="stdout") + stream.run(result) + self.assertEqual(b'', source.read()) -- cgit v1.2.1