返回 last30days-skill
test_runtime_preflight_contract.py
根目录 / tests / test_runtime_preflight_contract.py
1 """Contract tests for the SKILL.md runtime preflight snippet."""
2
3 import unittest
4 from pathlib import Path
5
6 ROOT = Path(__file__).resolve().parents[1]
7 SKILL_MD = ROOT / "skills" / "last30days" / "SKILL.md"
8
9
10 class RuntimePreflightContractTests(unittest.TestCase):
11 def setUp(self) -> None:
12 self.skill_md = SKILL_MD.read_text(encoding="utf-8")
13
14 def test_windows_localappdata_python_install_dir_is_scanned_first(self) -> None:
15 scan_command = 'find "$windows_python_root" -maxdepth 2 -type f -iname python.exe'
16
17 self.assertIn('windows_path_to_unix "$LOCALAPPDATA")/Programs/Python', self.skill_md)
18 self.assertIn('windows_path_to_unix "$ProgramFiles"', self.skill_md)
19 self.assertIn("printenv 'ProgramFiles(x86)'", self.skill_md)
20 self.assertIn("cygpath -u", self.skill_md)
21 self.assertIn(scan_command, self.skill_md)
22 self.assertNotIn("/c/Users/", self.skill_md)
23 self.assertNotIn("Python314/python.exe", self.skill_md)
24 self.assertLess(self.skill_md.index(scan_command), self.skill_md.index("python3.14"))
25
26 def test_candidate_selection_accepts_any_python_3_12_or_newer(self) -> None:
27 self.assertIn("try_last30days_python()", self.skill_md)
28 self.assertIn("sys.version_info >= (3, 12)", self.skill_md)
29
30 def test_preflight_allows_explicit_interpreter_override(self) -> None:
31 self.assertIn('if [ -z "${LAST30DAYS_PYTHON:-}" ]; then', self.skill_md)
32 self.assertIn('ERROR: LAST30DAYS_PYTHON must point to Python 3.12+.', self.skill_md)
33
34
35 if __name__ == "__main__":
36 unittest.main()
37
37 lines PYTHON