Fokko commented on code in PR #6532:
URL: https://github.com/apache/iceberg/pull/6532#discussion_r1064191436


##########
python/tests/avro/test_decoder.py:
##########
@@ -109,7 +109,7 @@ class OneByteAtATimeInputStream(InputStream):
 
     def read(self, size: int = 0) -> bytes:
         self.pos += 1
-        return int.to_bytes(1, self.pos, byteorder="little")
+        return self.pos.to_bytes(1, byteorder="little")

Review Comment:
   The test was actually incorrect. The `self.pos` is at the position of 
length, and the name (`OneByteAtATimeInputStream`) suggests that it only 
returns one byte at a time.
   
   Without the change, the test fails:
   ```
       def test_read_single_byte_at_the_time() -> None:
           decoder = BinaryDecoder(OneByteAtATimeInputStream())
   >       assert decoder.read(2) == b"\x01\x02"
   E       AssertionError: assert bytearray(b'\x01\x01\x00') == b'\x01\x02'
   E         At index 1 diff: 1 != 2
   E         Left contains one more item: 0
   E         Use -v to get more diff
   ```
   It will return more bytes each time it is called:
   
   <img width="586" alt="image" 
src="https://user-images.githubusercontent.com/1134248/211215078-ad04d82f-116f-4d29-a540-545860b4013f.png";>
   
   <img width="586" alt="image" 
src="https://user-images.githubusercontent.com/1134248/211215085-d52e6937-9d68-4c8d-a2fe-ff4ed5b5686a.png";>
   
   <img width="586" alt="image" 
src="https://user-images.githubusercontent.com/1134248/211215090-0d3bb081-a781-4910-8df4-77f253b7f2d5.png";>
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to