# -*- coding: utf-8 -*- """文档与 pytest 配置守护:防止模板标准退化。""" from __future__ import annotations import configparser import os import unittest from _support import get_skill_root class TestDocsStandards(unittest.TestCase): def _read(self, rel_path: str) -> str: path = os.path.join(get_skill_root(), rel_path) with open(path, encoding="utf-8") as f: return f.read() def test_rpa_md_covers_video_and_playwright_standards(self) -> None: text = self._read("references/RPA.md") self.assertIn("title", text) self.assertIn("closing_title", text) self.assertIn("中文", text) self.assertIn("--no-sandbox", text) self.assertIn("--disable-blink-features=AutomationControlled", text) self.assertIn("RpaVideoSession", text) self.assertIn("1.0.13", text) def test_adapter_md_covers_four_tiers_and_allow_flags(self) -> None: text = self._read("references/ADAPTER.md") for marker in ( "mock", "simulator_rpa", "real_api", "real_rpa", "ALLOW_REAL_API", "ALLOW_REAL_RPA", "ALLOW_WRITE_ACTIONS", "sibling_bridge", ): self.assertIn(marker, text, msg=f"ADAPTER.md missing {marker!r}") def test_cli_md_mentions_shared_python_runtime(self) -> None: text = self._read("references/CLI.md") self.assertIn("python-runtime", text) self.assertIn("uv run python", text) def test_testing_md_mentions_pytest_txt_collection_guard(self) -> None: text = self._read("references/TESTING.md") self.assertIn(".txt", text) self.assertIn("pytest.ini", text) def test_docs_do_not_claim_1_0_11_as_current_standard(self) -> None: for rel in ( "README.md", "SKILL.md", "references/RUNTIME.md", "references/RPA.md", "references/CONFIG.md", "references/TESTING.md", ): text = self._read(rel) self.assertNotIn( ">=1.0.11", text.replace(" ", ""), msg=f"{rel} still claims 1.0.11 as current minimum", ) class TestPytestIniCollection(unittest.TestCase): def test_pytest_ini_exists_and_limits_python_files(self) -> None: ini_path = os.path.join(get_skill_root(), "pytest.ini") self.assertTrue(os.path.isfile(ini_path), "pytest.ini must exist at repo root") parser = configparser.ConfigParser() parser.read(ini_path, encoding="utf-8") python_files = parser.get("pytest", "python_files", fallback="") self.assertIn("test_*.py", python_files) self.assertIn("*_test.py", python_files) if __name__ == "__main__": unittest.main()