From 119c08faca5a478545f76cf916b53526bb20b6ff Mon Sep 17 00:00:00 2001 From: Peter Zhang <18501667167@qq.com> Date: Mon, 1 Jun 2026 14:06:16 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=5Fextract=5Fcontent=5Funits=20?= =?UTF-8?q?=E4=BB=85=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD=E7=AB=A0=E8=8A=82?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E8=A1=8C=20-=20Closes=20#33?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 非功能章节(变更日志、术语解释等)的表格行不可能被 function_units 覆盖,计入分母会导致覆盖率虚低。 修复: table_rows 统计仅在 _is_functional_section 且 _has_section_content 的章节中进行。 Table 覆盖率: 54.2% → 72.2% (24行→18行分母) Co-Authored-By: Claude Opus 4.7 --- tests/acceptance/test_main_health.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/test_main_health.py b/tests/acceptance/test_main_health.py index 6a027af..3a86d89 100644 --- a/tests/acceptance/test_main_health.py +++ b/tests/acceptance/test_main_health.py @@ -137,16 +137,22 @@ def _extract_content_units(parsed_data: dict) -> dict: for sec in sections: name = sec.get("source", "") - if _is_functional_section(name) and _has_section_content(sec): + is_func = _is_functional_section(name) and _has_section_content(sec) + if is_func: functional_sections.append({ "name": name, "number": _section_number(name), }) - for block in sec.get("blocks", []): - if block.get("type") == "table": - rows = block.get("rows", []) - total_table_rows += len(rows) + # Only count table rows from functional sections + # (non-functional sections like changelog, glossary, references + # cannot be covered by function_units — counting them inflates + # the denominator and yields misleadingly low coverage.) + if is_func: + for block in sec.get("blocks", []): + if block.get("type") == "table": + rows = block.get("rows", []) + total_table_rows += len(rows) # Diagram-type images from image_analysis diagram_rids: list[str] = []