testing
import testingThe testing module is a small, pure-py4 test helper that layers over the runtime assertion mechanism.
Functions
| Signature | Description |
|---|---|
testing.fail(msg: str) -> None | Unconditionally fail with message |
testing.assert_true(value: bool) -> None | Fail if value is False |
testing.assert_false(value: bool) -> None | Fail if value is True |
testing.assert_eq(a, b) -> None | Fail if a != b (int, float, bool, char, str) |
testing.assert_ne(a, b) -> None | Fail if a == b (int, float, bool, char, str) |
Example
import testing
def main() -> None: testing.assert_true(True) testing.assert_false(False) testing.assert_eq(3, 3) testing.assert_eq(1.5, 1.5) testing.assert_eq('x', 'x') testing.assert_eq("py4", "py4") testing.assert_ne(3, 4) testing.assert_ne("aa", "ab") print("ok")Notes
- Failures write to stderr and exit the process — same as
assert. - Deep structural equality for lists, dicts, tuples, and classes is not yet supported; compare scalar fields manually.
- The module is intentionally minimal. There is no test runner, test registration, or reporting framework.