Show More
@@ -925,6 +925,11 b' class bufferingdecoder(object):' | |||
|
925 | 925 | * Integer number of bytes decoded from the new input. |
|
926 | 926 | * Integer number of bytes wanted to decode the next value. |
|
927 | 927 | """ |
|
928 | # We /might/ be able to support passing a bytearray all the | |
|
929 | # way through. For now, let's cheat. | |
|
930 | if isinstance(b, bytearray): | |
|
931 | b = bytes(b) | |
|
932 | ||
|
928 | 933 | # Our strategy for buffering is to aggregate the incoming chunks in a |
|
929 | 934 | # list until we've received enough data to decode the next item. |
|
930 | 935 | # This is slightly more complicated than using an ``io.BytesIO`` |
@@ -965,6 +965,14 b' class BufferingDecoderTests(TestCase):' | |||
|
965 | 965 | |
|
966 | 966 | self.assertEqual(decoder.getavailable(), [source]) |
|
967 | 967 | |
|
968 | def testbytearray(self): | |
|
969 | source = b''.join(cborutil.streamencode(b'foobar')) | |
|
970 | ||
|
971 | decoder = cborutil.bufferingdecoder() | |
|
972 | decoder.decode(bytearray(source)) | |
|
973 | ||
|
974 | self.assertEqual(decoder.getavailable(), [b'foobar']) | |
|
975 | ||
|
968 | 976 | class DecodeallTests(TestCase): |
|
969 | 977 | def testemptyinput(self): |
|
970 | 978 | self.assertEqual(cborutil.decodeall(b''), []) |
General Comments 0
You need to be logged in to leave comments.
Login now