# -*- coding: utf-8 -*- """ 一键复验入口 (AGENTS.md §1.4 / §5.9) .venv/bin/python -m tcaptcha.selftest """ from __future__ import annotations import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] SUITES = [ "tcaptcha.tests.test_crypto_core", "tcaptcha.tests.test_glyph_solver", "tcaptcha.tests.test_xtea_key", "tcaptcha.tests.test_tdc_key", ] def main() -> int: failed = [] for mod in SUITES: print(f"\n{'=' * 62}\n>>> {mod}\n{'=' * 62}") rc = subprocess.run([sys.executable, "-m", mod], cwd=str(ROOT), env={**__import__("os").environ, "PYTHONPATH": str(ROOT)}).returncode if rc != 0: failed.append(mod) print(f"\n{'=' * 62}") if failed: print(f"❌ selftest 失败: {failed}") return 1 print("✅ selftest 全部通过") return 0 if __name__ == "__main__": raise SystemExit(main())