"""`scripts/terminal-evidence/tests/` 를 문서에 적힌 한 명령이 함께 돌게 잇는다. `python3 -m unittest discover -s scripts/tests` 는 그 폴더만 훑는다. 터미널 증거 렌더러의 테스트는 `scripts/terminal-evidence/tests/` 에 따로 있어서 그 명령에 안 잡혔고, `verify-pipeline.py` 도 unittest 를 부르지 않는다. 그래서 **초록인데 아무도 안 부르는 회귀**가 됐다. `discover -s scripts/terminal-evidence/tests` 를 직접 돌려도 깨진다 — 그 테스트가 `render_terminal` 을 같은 폴더 기준으로 부르는데 그 경로가 `sys.path` 에 없다. 여기서 경로를 얹고 파일을 직접 불러 `load_tests` 로 끌어온다. 중첩 `discover` 는 쓰지 않는다 — `top_level_dir` 이 바깥을 가리키면 unittest 가 거절한다. """ from __future__ import annotations import importlib.util import os import sys import unittest _HERE = os.path.dirname(os.path.abspath(__file__)) _TE = os.path.join(os.path.dirname(_HERE), "terminal-evidence") _TE_TESTS = os.path.join(_TE, "tests") def load_tests(loader: unittest.TestLoader, tests: unittest.TestSuite, pattern: str | None) -> unittest.TestSuite: if not os.path.isdir(_TE_TESTS): return tests if _TE not in sys.path: sys.path.insert(0, _TE) for name in sorted(os.listdir(_TE_TESTS)): if not (name.startswith("test") and name.endswith(".py")): continue mod_name = "terminal_evidence_" + name[:-3] spec = importlib.util.spec_from_file_location( mod_name, os.path.join(_TE_TESTS, name)) if spec is None or spec.loader is None: continue module = importlib.util.module_from_spec(spec) sys.modules[mod_name] = module spec.loader.exec_module(module) tests.addTests(loader.loadTestsFromModule(module)) return tests