Example #1
0
def test_debug():
    path = os.path.join(os.path.dirname(__file__), "debug.bin")
    with open(path, "rb") as f:
        orig = f.read()
        decode1 = decode_luabins(BytesIO(orig))
        re_encoded = encode_luabins(decode1)
        decode2 = decode_luabins(BytesIO(re_encoded))
        assert decode2 == decode1
Example #2
0
def open_and_assert(filename, expected):
    path = os.path.join(os.path.dirname(__file__), filename)
    with open(path, "rb") as f:
        assert decode_luabins(f) == expected

    path = os.path.join(os.path.dirname(__file__), "output_" + filename)
    with open(path, "wb") as f:
        f.write(encode_luabins(expected))
 def to_bytes(self) -> bytes:
     if self.version <= 14:
         return encode_luabins(self.to_dicts())
     else:
         return lz4.block.compress(encode_luabins(self.to_dicts()),
                                   store_size=False)
 def to_bytes(self) -> bytes:
     return encode_luabins(self.to_dicts())
Example #5
0
def assert_save_load(value: List[Any], comparison_value=None):
    comparison_value = comparison_value or value
    assert decode_luabins(BytesIO(encode_luabins(value))) == comparison_value