From b2241d0e2192e3c46d9b7912ab30fc4e29140ba1 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 2 Oct 2026 23:12:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(test):=20=E4=BF=AE=E5=A4=8D=20test=5F2035?= =?UTF-8?q?=5Fcoverage=20=E5=9B=A0=E7=A7=BB=E9=99=A4=20points=5Fgate=20imp?= =?UTF-8?q?ort=20=E5=AF=BC=E8=87=B4=E7=9A=84=E9=94=9A=E7=82=B9=E5=A4=B1?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原测试用 'from packages.middleware' 作为代码片段结束锚点,PR #2150 移除 generation_tasks 中未使用的 points_gate import 后,该字符串消失导致 collection 阶段 ValueError: substring not found。改用紧跟 _infer_expected_categories 后的 'logger = logging.getLogger' 行作为更稳定的结束锚点。 --- tests/unit/test_2035_coverage.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_2035_coverage.py b/tests/unit/test_2035_coverage.py index b8bbedf6d..7c682b876 100644 --- a/tests/unit/test_2035_coverage.py +++ b/tests/unit/test_2035_coverage.py @@ -87,7 +87,9 @@ _GEN_TASKS_PATH = Path(__file__).resolve().parents[2] / "apps/api/app/api/routes def _load_infer_func(): src = _GEN_TASKS_PATH.read_text() start = src.index("# #2035:文案关键词") - end = src.index("from packages.middleware") + # 用紧跟 _infer_expected_categories 后的 logger 行作为结束锚点 + end_marker = "\nlogger = logging.getLogger" + end = src.index(end_marker, start) code = src[start:end] ns: dict = {} exec(code, ns)