testing | Modular
Mojo module
Implements various testing utils.
You can import these APIs from the testing package. For example:
from testing import assert_true
def main():
x = 1
y = 2
try:
assert_true(x==1)
assert_true(y==2)
assert_true((x+y)==3)
print("All assertions succeeded")
except e:
print("At least one assertion failed:")
print(e)Structs
-
assert_raises: Context manager that asserts that the block raises an exception.
Functions
-
assert_almost_equal: Asserts that the input values are equal up to a tolerance. If it is not then an Error is raised. -
assert_equal: Asserts that the input values are equal. If it is not then an Error is raised. -
assert_equal_pyobj: Asserts that thePythonObjects are equal. If it is not then an Error is raised. -
assert_false: Asserts that the input value is False and raises an Error if it's not. -
assert_is: Asserts that the input values have the same identity. If they do not then an Error is raised. -
assert_is_not: Asserts that the input values have different identities. If they do not then an Error is raised. -
assert_not_equal: Asserts that the input values are not equal. If it is not then an Error is raised. -
assert_true: Asserts that the input value is True and raises an Error if it's not.