comparison tests/test-cbor.py @ 40124:b638219a23c3

cborutil: cast bytearray to bytes This code didn't like passing in bytearray instances. Let's cast bytearray to bytes so it works. Differential Revision: https://phab.mercurial-scm.org/D4914
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 04 Oct 2018 15:08:42 -0700
parents babad5ebaf0a
children a9905045b992
comparison
equal deleted inserted replaced
40123:627b0f9baeaf 40124:b638219a23c3
963 decoder.decode(encoded[start:start + step]) 963 decoder.decode(encoded[start:start + step])
964 start += step 964 start += step
965 965
966 self.assertEqual(decoder.getavailable(), [source]) 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 class DecodeallTests(TestCase): 976 class DecodeallTests(TestCase):
969 def testemptyinput(self): 977 def testemptyinput(self):
970 self.assertEqual(cborutil.decodeall(b''), []) 978 self.assertEqual(cborutil.decodeall(b''), [])
971 979
972 def testpartialinput(self): 980 def testpartialinput(self):