Пример #1
0
 def test_from_string(self):
     val = Bytes.from_string("87349DBC")
     assert val.value() == b'\x87\x34\x9d\xbc'
Пример #2
0
 def test_encode_null(self):
     val = Bytes(None)
     assert val.encode() == b'\xff\xff'
Пример #3
0
 def test_str(self):
     val = Bytes(b'\x87\x34\x9d\xbc')
     print(str(val))
     assert str(val) == "87349dbc (bytes)"
     assert repr(val) == "<Bytes length=4>"
Пример #4
0
 def test_encode(self):
     val = Bytes(b'\x87\x34\x9d\xbc')
     print(repr(val.encode()))
     assert val.encode() == b'\x00\x04\x87\x34\x9d\xbc'
Пример #5
0
 def test_decode_remainder(self):
     (val, rest) = Bytes.decode(b'\x00\x04\x87\x34\x9d\xbcabc')
     assert rest == b'abc'
Пример #6
0
 def test_decode_null(self):
     (val, rest) = Bytes.decode(b'\xff\xff')
     assert isinstance(val, Bytes)
     assert val.value() is None
     assert rest == b''
Пример #7
0
 def test_decode(self):
     (val, rest) = Bytes.decode(b'\x00\x04\x87\x34\x9d\xbc')
     assert isinstance(val, Bytes)
     assert val.value() == b'\x87\x34\x9d\xbc'
     assert rest == b''
Пример #8
0
 def test_from_string_null(self):
     val = Bytes.from_string(None)
     assert val.value() is None