simvx.core.testing.selftest¶
Exit codes for the headless self-checks examples run behind --test.
Three outcomes, three codes::
0 the mechanic works
1 the mechanic is broken
2 this environment cannot answer the question
Without the third, an example that needs an optional package (or a device this machine has not got) either fails as though the mechanic were broken or passes as though the fallback it measured were the thing under test. Raise
- class:
Unsupportedfrom inside the check to say so, and let- func:
run_selftestturn it into the exit code::def _selftest() -> bool: … if backend != “JoltPhysics”: raise Unsupported(“install simvx-physics-jolt to check the Jolt half”) print(“SELFTEST:”, “PASS” if ok else “FAIL”) return ok
if “–test” in sys.argv: sys.exit(run_selftest(_selftest))
Report the checks that DID run before raising: a check that ran on a fallback still says something, and a failure among them is a genuine failure, so raise only once nothing else has gone wrong.
Module Contents¶
Functions¶
Run check and return the process exit code for its outcome. |
Data¶
API¶
- simvx.core.testing.selftest.__all__¶
[‘SELFTEST_FAIL’, ‘SELFTEST_PASS’, ‘SELFTEST_UNSUPPORTED’, ‘Unsupported’, ‘run_selftest’]
- simvx.core.testing.selftest.SELFTEST_PASS¶
0
- simvx.core.testing.selftest.SELFTEST_FAIL¶
1
- simvx.core.testing.selftest.SELFTEST_UNSUPPORTED¶
2
- exception simvx.core.testing.selftest.Unsupported[source]¶
Bases:
ExceptionRaised by a self-check whose environment lacks a capability it needs.
The message says which capability, and how to get it where that is actionable (“install simvx-physics-jolt”). It is not a failure: the question was never put to the code under test.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- class __cause__¶
- class __context__¶
- __delattr__()¶
- __dir__()¶
- __eq__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __le__()¶
- __lt__()¶
- __ne__()¶
- __new__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __setattr__()¶
- __setstate__()¶
- __sizeof__()¶
- __str__()¶
- __subclasshook__()¶
- class __suppress_context__¶
- class __traceback__¶
- add_note()¶
- class args¶
- with_traceback()¶
- simvx.core.testing.selftest.run_selftest(check: collections.abc.Callable[[], bool]) int[source]¶
Run check and return the process exit code for its outcome.
SELFTEST_PASSwhen it returns true,SELFTEST_FAILwhen it returns false,SELFTEST_UNSUPPORTEDwhen it raises :class:Unsupported. Any other exception propagates: an unexpected traceback is a failure worth seeing in full, not an exit code.