288 parser = argparse.ArgumentParser(description=
"Instrumentation Self-Test (CLI)")
292 help=
"Use global debug levels instead of forcing maximum verbosity",
294 args = parser.parse_args()
296 force_verbose =
not args.use_global
298 print(
"\nINSTRUMENTATION SELF-TEST (CLI)")
299 print(
"Instrumentation enabled:", _ud.INSTRUMENTATION_ENABLED)
300 print(
"FORCE VERBOSE MODE:", force_verbose)
305 _save_enabled = _ud.INSTRUMENTATION_ENABLED
306 _save_instr_level = DEBUG_LEVELS.get(
"INSTRUMENTATION", 0)
307 _save_ui_level = DEBUG_LEVELS.get(
"UI", 0)
313 _ud.INSTRUMENTATION_ENABLED =
True
316 DEBUG_LEVELS[
"INSTRUMENTATION"] = 9
317 DEBUG_LEVELS[
"UI"] = 9
318 _dbg(
"TEST",
"debug_levels",
"FORCING MAX VERBOSITY", override=
True)
320 _dbg(
"TEST",
"debug_levels",
"Using GLOBAL debug levels", override=
True)
328 test_structural_protection,
329 test_custom_component_behavior,
333 failures: list[str] = []
338 print(f
" PASS {fn.__name__}")
339 except AssertionError
as exc:
340 print(f
" FAIL {fn.__name__}: {exc}")
341 failures.append(fn.__name__)
342 except Exception
as exc:
343 print(f
" ERROR {fn.__name__}: {type(exc).__name__}: {exc}")
344 failures.append(fn.__name__)
349 _ud.INSTRUMENTATION_ENABLED = _save_enabled
350 DEBUG_LEVELS[
"INSTRUMENTATION"] = _save_instr_level
351 DEBUG_LEVELS[
"UI"] = _save_ui_level
356 print(
"\n" +
"=" * 70)
359 f
"CLI SELF-TEST FAILED: {len(failures)}/{len(tests)} test(s) failed"
361 print(f
" Failed: {', '.join(failures)}")
365 print(f
"CLI SELF-TEST PASSED: {len(tests)}/{len(tests)} tests passed")