diff --git a/tests/test_issue4002_shutdown_i18n_code_spans.py b/tests/test_issue4002_shutdown_i18n_code_spans.py index 9f73ba43..b16bd500 100644 --- a/tests/test_issue4002_shutdown_i18n_code_spans.py +++ b/tests/test_issue4002_shutdown_i18n_code_spans.py @@ -1,19 +1,34 @@ from pathlib import Path -import re REPO = Path(__file__).resolve().parents[1] +def _extract_function(src: str, name: str) -> str: + anchor = f"function {name}(" + start = src.find(anchor) + assert start != -1, f"{name}() must exist" + body_start = src.find("{", start) + assert body_start != -1, f"{name}() must have a body" + depth = 1 + idx = body_start + 1 + while depth and idx < len(src): + if src[idx] == "{": + depth += 1 + elif src[idx] == "}": + depth -= 1 + idx += 1 + assert depth == 0, f"{name}() body must balance braces" + return src[start:idx] + + def test_shutdown_description_uses_split_i18n_spans_in_index_html(): html = (REPO / "static" / "index.html").read_text(encoding="utf-8") - block_match = re.search( - r'