MCPcopy Create free account
hub / github.com/apache/tvm-ffi / test_error_from_cxx

Function test_error_from_cxx

tests/python/test_error.py:38–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37
38def test_error_from_cxx() -> None:
39 test_raise_error = tvm_ffi.get_global_func("testing.test_raise_error")
40
41 try:
42 test_raise_error("ValueError", "error XYZ")
43 except ValueError as e:
44 assert e.__tvm_ffi_error__.kind == "ValueError" # ty: ignore[unresolved-attribute]
45 assert e.__tvm_ffi_error__.message == "error XYZ" # ty: ignore[unresolved-attribute]
46 assert e.__tvm_ffi_error__.backtrace.find("TestRaiseError") != -1 # ty: ignore[unresolved-attribute]
47
48 fapply = tvm_ffi.convert(lambda f, *args: f(*args))
49
50 with pytest.raises(TypeError):
51 fapply(test_raise_error, "TypeError", "error XYZ")
52
53 # wrong number of arguments
54 with pytest.raises(TypeError):
55 tvm_ffi.convert(lambda x: x)()
56
57
58def test_error_from_nested_pyfunc() -> None:

Callers

nothing calls this directly

Calls 4

test_raise_errorFunction · 0.85
fapplyFunction · 0.85
findMethod · 0.45
convertMethod · 0.45

Tested by

no test coverage detected