def test_read_zero(self): encoded = b('\x00crummy') infile = BytesIO(encoded) (decoded, read) = varblock.read_varint(infile) # Test the returned values self.assertEqual(0, decoded) self.assertEqual(1, read) # The rest of the file should be untouched self.assertEqual(b('crummy'), infile.read())
def test_read_varint(self): encoded = "\xac\x02crummy" infile = StringIO(encoded) (decoded, read) = varblock.read_varint(infile) # Test the returned values self.assertEqual(300, decoded) self.assertEqual(2, read) # The rest of the file should be untouched self.assertEqual("crummy", infile.read())