def test_chars_padding_added(self): u = Fields() u.add(CH(6, 'string')) u.string = '1234' data = u.pack() assert data == bytearray.fromhex('31 32 33 34 00 00')
def test_chars_too_long(self): u = Fields() u.add(CH(6, 'string')) u.string = '1234567' # One byte too long with pytest.raises(ValueError): u.pack()
def test_basic_pack(self): u = Fields() u.add(CH(4, 'string')) u.string = '1234' data = u.pack() assert data == bytearray.fromhex("31 32 33 34")