BUG FIXES
authorRobert Collins <robertc@robertcollins.net>
Sun, 12 May 2013 22:46:55 +0000 (10:46 +1200)
committerRobert Collins <robertc@robertcollins.net>
Sun, 12 May 2013 22:46:55 +0000 (10:46 +1200)
~~~~~~~~~

* Subunit v2 packets with both file content and route code were not being
  parsed correctly - they would incorrectly emit a parser error, due to trying
  to parse the route code length from the first byes of the file content.
  (Robert Collins, 1172815)

NEWS
python/subunit/tests/test_test_protocol2.py
python/subunit/v2.py

diff --git a/NEWS b/NEWS
index 4048c12eaafe42b072465829147a852817086ceb..731a3b7bf662d4b0a6a0d154e40bd0b3d2cede6c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,14 @@ subunit release notes
 NEXT (In development)
 ---------------------
 
+BUG FIXES
+~~~~~~~~~
+
+* Subunit v2 packets with both file content and route code were not being
+  parsed correctly - they would incorrectly emit a parser error, due to trying
+  to parse the route code length from the first byes of the file content.
+  (Robert Collins, 1172815)
+
 0.0.11
 ------
 
index 002efa70846ad62c4ed6144117914e19a326dbdf..583c5509186e8fee4083eb963cdb962cf51bcfe3 100644 (file)
@@ -408,6 +408,14 @@ class TestByteStreamToStreamResult(TestCase):
                     b'packet: claimed 63 bytes, 10 available'),
             ])
 
+    def test_route_code_and_file_content(self):
+        content = BytesIO()
+        subunit.StreamResultToBytes(content).status(
+            route_code='0', mime_type='text/plain', file_name='bar',
+            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')
+
 
 def test_suite():
     loader = subunit.tests.TestUtil.TestLoader()
index bbc20da22b400a0712f49fbfcdd1edb7df41f315..91d53f9c0de28c92fac80d5c9346f7e6fac10385 100644 (file)
@@ -423,6 +423,7 @@ class ByteStreamToStreamResult(object):
                     raise ParseError('File content extends past end of packet: '
                         'claimed %d bytes, %d available' % (
                         content_length, len(file_bytes)))
+                pos += content_length
             else:
                 file_name = None
                 file_bytes = None