From c982df4cf0705be79f1f64570d8cca7814988146 Mon Sep 17 00:00:00 2001 From: zhanghuanxu Date: Thu, 2 Jul 2026 17:37:51 +0800 Subject: [PATCH] test: inline slide lint XML fixtures --- .../scripts/xml_text_overlap_lint_test.py | 66 ++++++++++++++----- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/skills/lark-slides/scripts/xml_text_overlap_lint_test.py b/skills/lark-slides/scripts/xml_text_overlap_lint_test.py index 69114347..cace60cd 100644 --- a/skills/lark-slides/scripts/xml_text_overlap_lint_test.py +++ b/skills/lark-slides/scripts/xml_text_overlap_lint_test.py @@ -3,16 +3,12 @@ from __future__ import annotations import unittest -from pathlib import Path import xml_text_overlap_lint -TEMPLATES_DIR = Path(__file__).resolve().parents[1] / "assets" / "templates" - - class XmlTextOverlapLintTest(unittest.TestCase): - def assertNoXmlTextOverlapLintIssues(self, result: dict, template_path: Path) -> None: + def assertNoXmlTextOverlapLintIssues(self, result: dict, sample_name: str) -> None: issue_summaries = [] for slide in result.get("slides", []): for issue in slide.get("issues", []): @@ -25,24 +21,64 @@ class XmlTextOverlapLintTest(unittest.TestCase): self.assertEqual( result["summary"]["error_count"], 0, - f"{template_path.name} has XML text overlap lint errors:\n" + "\n".join(issue_summaries), + f"{sample_name} has XML text overlap lint errors:\n" + "\n".join(issue_summaries), ) self.assertEqual( result["summary"]["warning_count"], 0, - f"{template_path.name} has XML text overlap lint warnings:\n" + "\n".join(issue_summaries), + f"{sample_name} has XML text overlap lint warnings:\n" + "\n".join(issue_summaries), ) - def test_xml_text_overlap_lint_accepts_all_template_xml_files(self) -> None: - template_paths = sorted(TEMPLATES_DIR.glob("*.xml")) - self.assertTrue(template_paths) - for template_path in template_paths: - with self.subTest(template=template_path.name): + def test_xml_text_overlap_lint_accepts_inline_fixture_xml_samples(self) -> None: + samples = { + "image-led-cover": """ + + + + + + +

Quarterly Review

+
+ +

Focus, progress, and next steps

+
+
+
+
+ """, + "content-grid": """ + + + + +

Execution Snapshot

+
+ + +

Plan

+
+ + +

Build

+
+ + +

Launch

+
+
+
+
+ """, + } + self.assertTrue(samples) + for sample_name, sample_xml in samples.items(): + with self.subTest(sample=sample_name): result = xml_text_overlap_lint.lint_xml( - template_path.read_text(encoding="utf-8"), - str(template_path), + sample_xml, + sample_name, ) - self.assertNoXmlTextOverlapLintIssues(result, template_path) + self.assertNoXmlTextOverlapLintIssues(result, sample_name) def test_lint_xml_reports_unescaped_ampersand_in_text(self) -> None: result = xml_text_overlap_lint.lint_xml(