Option C oc_diagnostics
Loading...
Searching...
No Matches
run_tests Namespace Reference

Functions

 _record (str status, str name, str detail="")
 _run (str name, fn)
 _run_cli_selftest ()
 main ()

Variables

 _REPO_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
 _TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
str PASS = "PASS"
str FAIL = "FAIL"
str SKIP = "SKIP"
list _results = []

Detailed Description

Test Runner — oc_diagnostics
=============================

Purpose
-------
Execute the full ``oc_diagnostics`` test suite from the command line by
importing and running all individual per-module test files via a lightweight
PASS/FAIL/SKIP reporting infrastructure.

Responsibilities
----------------
- Import test functions from each per-module test file and run them via the
  internal ``_run()`` wrapper, which catches ``AssertionError`` and
  unexpected exceptions and records PASS / FAIL / SKIP accordingly.
- Handle Dash-optional test modules cleanly: attempt import and skip with a
  clear message when Dash is absent.
- Invoke ``instrumentation_selftest_cli`` as a subprocess when Dash is
  available; treat a non-zero exit code as a test failure.
- Collect PASS/SKIP/FAIL per test, print a structured summary, and exit
  with code ``0`` on full success or ``1`` on any failure.

Diagnostics
-----------
Domain: TEST
Levels:
    L2 — lifecycle
    L3 — semantic details
    L4 — deep tracing

Contracts
---------
- Must exit ``0`` only when all non-skipped tests pass.
- Must exit ``1`` when any test fails or raises an unexpected exception.
- Core tests must run without Dash, FastAPI, or any optional dependency.
- Must not start a Dash server or produce interactive UI.
- Must not modify global oc_diagnostics state permanently; any state
  changes made during tests must be restored before the test exits.

Modules covered by this test suite
-----------------------------------
- unified_debug
- logging_handler
- fastapi_middleware
- id_instrumentation
- instrumentation_middleware
- ui_event_logger
- instrumentation_selftest_cli
- instrumentation_selftest_app

Function Documentation

◆ _record()

run_tests._record ( str status,
str name,
str detail = "" )
protected

Definition at line 86 of file run_tests.py.

Here is the caller graph for this function:

◆ _run()

run_tests._run ( str name,
fn )
protected

Definition at line 94 of file run_tests.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _run_cli_selftest()

run_tests._run_cli_selftest ( )
protected
Run instrumentation_selftest_cli as a subprocess.

Definition at line 108 of file run_tests.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

run_tests.main ( )

Definition at line 140 of file run_tests.py.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _REPO_ROOT

run_tests._REPO_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
protected

Definition at line 64 of file run_tests.py.

◆ _results

list run_tests._results = []
protected

Definition at line 83 of file run_tests.py.

◆ _TESTS_DIR

run_tests._TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
protected

Definition at line 70 of file run_tests.py.

◆ FAIL

str run_tests.FAIL = "FAIL"

Definition at line 80 of file run_tests.py.

◆ PASS

str run_tests.PASS = "PASS"

Definition at line 79 of file run_tests.py.

◆ SKIP

str run_tests.SKIP = "SKIP"

Definition at line 81 of file run_tests.py.