junrushao commented on code in PR #334:
URL: https://github.com/apache/tvm-ffi/pull/334#discussion_r2612947146
##########
tests/python/test_stl.py:
##########
@@ -31,33 +30,25 @@ def test_stl() -> None:
mod: Module = tvm_ffi.load_module(output_lib_path)
- def run_check(mod: Module) -> None:
- # This sub function is needed to make sure all temp variables
deallocated
- # before module unload since some of these objects contains deleters
in the library
- # code. If the module is unloaded before the object is deleted, the
deleter
- # may call an invalid address.
- assert list(mod.test_tuple([1, 2.5])) == [2.5, 1]
- assert mod.test_vector(None) is None
- assert list(mod.test_vector([[1, 2], [3, 4]])) == [3, 7]
- assert mod.test_variant(1) == "int"
- assert mod.test_variant(1.0) == "float"
- assert list(mod.test_variant([1, 1.0])) == ["int", "float"]
- assert dict(mod.test_map({"a": 1, "b": 2})) == {1: "a", 2: "b"}
- assert dict(mod.test_map_2({"a": 1, "b": 2})) == {1: "a", 2: "b"}
- assert mod.test_function(lambda: 0)() == 1
- assert mod.test_function(lambda: 10)() == 11
-
- with pytest.raises(TypeError):
- mod.test_tuple([1.5, 2.5])
- with pytest.raises(TypeError):
- mod.test_function(lambda: 0)(100)
-
- run_check(mod)
- # Force garbage collection to ensure that all objects created from the
- # module are destroyed before the module itself is unloaded. This
- # prevents segfaults from calling destructors in an unloaded library.
- gc.collect()
- del mod
+ # This sub function is needed to make sure all temp variables deallocated
Review Comment:
I removed the comments - sub functions are not super desirable given the
test doesn't really have a structure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]