"""技术暗标 HTML 格式检查:结构校验与极简用例(标准库 unittest)。""" import json import os import sys import unittest # 保证可 `python tests/test_*.py` 从项目根导入 `modules` _ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if _ROOT not in sys.path: sys.path.insert(0, _ROOT) from modules.dark_bid_format_check import check_technical_bid # noqa: E402 def _sample_schema_path(): return os.path.join(os.path.dirname(__file__), "fixtures", "dark_bid_report_sample.json") class TestDarkBidFormatCheck(unittest.TestCase): def test_sample_fixture_keys(self): with open(_sample_schema_path(), encoding="utf-8") as f: sample = json.load(f) self.assertIn("overall", sample) self.assertIn("details", sample) self.assertIn("violations", sample) for d in sample["details"]: self.assertTrue({"rule", "passed", "message"}.issubset(d.keys())) def test_check_returns_structure(self): html = """
正文内容示例。
""" r = check_technical_bid(html) self.assertIsInstance(r["overall"], bool) self.assertEqual(len(r["details"]), 7) rules = [x["rule"] for x in r["details"]] self.assertIn("身份信息隐藏", rules) self.assertIn("标题格式", rules) def test_empty_html(self): r = check_technical_bid("") self.assertFalse(r["overall"]) def test_identity_fail_on_company(self): html = ( "我公司参与投标
" "