summaryrefslogtreecommitdiff
path: root/python/subunit/tests
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2015-08-04 15:38:46 +1200
committerRobert Collins <robertc@robertcollins.net>2015-08-04 15:38:46 +1200
commit201f6f45708bf40e931d578a4460a356e9515cde (patch)
treeeda0abedbafa7bae7c51cd1d0da2556a5045c063 /python/subunit/tests
parentc90fc5d0a74f7bc8a7e0d9c846c2d0f46b97f8d2 (diff)
downloadsubunit-201f6f45708bf40e931d578a4460a356e9515cde.tar.gz
Handle very short packets
Yay quickcheck.
Diffstat (limited to 'python/subunit/tests')
-rw-r--r--python/subunit/tests/test_test_protocol2.py14
1 files changed, 14 insertions, 0 deletions
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())