Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_deserialize():
serialized_module = Module(TEST_BYTES).serialize()
module = Module.deserialize(serialized_module)
del serialized_module
assert module.instantiate().exports.sum(1, 2) == 3
def test_compile():
assert isinstance(Module(TEST_BYTES), Module)
def test_instantiate():
assert Module(TEST_BYTES).instantiate().exports.sum(1, 2) == 3
def test_failed_to_compile():
with pytest.raises(RuntimeError) as context_manager:
Module(INVALID_TEST_BYTES)
exception = context_manager.value
assert str(exception) == (
'Failed to compile the module:\n Validation error "Invalid type"'
)
def test_serialize():
assert type(Module(TEST_BYTES).serialize()) == bytes