diff options
author | Robert Collins <robertc@robertcollins.net> | 2013-08-25 01:51:28 +1200 |
---|---|---|
committer | Robert Collins <robertc@robertcollins.net> | 2013-08-25 01:51:28 +1200 |
commit | cdde85af0120db47b054d8e23012b5784d3960de (patch) | |
tree | 6c839c5c4538b80ce2875a51bde7f1d52e8601cd | |
parent | 4c7487178b034ecdb855ce908c1163f8199c756d (diff) | |
download | subunit-cdde85af0120db47b054d8e23012b5784d3960de.tar.gz |
* Clients of subunit did not expect memoryview objects in StreamResult events.
(Robert Collins)
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | python/subunit/tests/test_test_protocol2.py | 4 | ||||
-rw-r--r-- | python/subunit/v2.py | 4 |
3 files changed, 14 insertions, 0 deletions
@@ -5,6 +5,12 @@ subunit release notes NEXT (In development) --------------------- +BUG FIXES +~~~~~~~~~ + +* Clients of subunit did not expect memoryview objects in StreamResult events. + (Robert Collins) + 0.0.14 ------ diff --git a/python/subunit/tests/test_test_protocol2.py b/python/subunit/tests/test_test_protocol2.py index ded56b8..f88e0aa 100644 --- a/python/subunit/tests/test_test_protocol2.py +++ b/python/subunit/tests/test_test_protocol2.py @@ -303,6 +303,10 @@ class TestByteStreamToStreamResult(TestCase): source, non_subunit_name="stdout").run(result) self.assertEqual(b'', source.read()) self.assertEqual(events, result._events) + #- any file attachments should be byte contents [as users assume that]. + for event in result._events: + if event[5] is not None: + self.assertIsInstance(event[6], bytes) def check_event(self, source_bytes, test_status=None, test_id="foo", route_code=None, timestamp=None, tags=None, mime_type=None, diff --git a/python/subunit/v2.py b/python/subunit/v2.py index 0a7796f..1f5bfc1 100644 --- a/python/subunit/v2.py +++ b/python/subunit/v2.py @@ -385,8 +385,10 @@ class ByteStreamToStreamResult(object): % (crc, packet_crc)) if safe_hasattr(builtins, 'memoryview'): body = memoryview(packet[-1]) + view = True else: body = packet[-1] + view = False # Discard CRC-32 body = body[:-4] # One packet could have both file and status data; the Python API @@ -421,6 +423,8 @@ class ByteStreamToStreamResult(object): content_length, consumed = self._parse_varint(body, pos) pos += consumed file_bytes = body[pos:pos+content_length] + if view: + file_bytes = file_bytes.tobytes() if len(file_bytes) != content_length: raise ParseError('File content extends past end of packet: ' 'claimed %d bytes, %d available' % ( |