test(md2doc): fix pStyle attribute + case-insensitive color compare

This commit is contained in:
2026-07-28 10:24:55 +03:00
parent 36b6a16fd8
commit 162485bfb2
+5 -4
View File
@@ -27,8 +27,9 @@ def test_render_h1_uses_heading1_style_and_text():
node = BeautifulSoup("<h1>My Title</h1>", "html.parser").find("h1") node = BeautifulSoup("<h1>My Title</h1>", "html.parser").find("h1")
_render_heading(doc, node, level=1, style=style) _render_heading(doc, node, level=1, style=style)
root = get_doc_xml(doc) root = get_doc_xml(doc)
pStyles = [p.text for p in root.iter(f"{{{W_NS}}}pStyle")] # pStyle is an attribute, not text content
assert "Heading1" in pStyles pStyle_vals = [p.get(f"{{{W_NS}}}val") for p in root.iter(f"{{{W_NS}}}pStyle")]
assert "Heading1" in pStyle_vals
texts = [t.text for t in root.iter(f"{{{W_NS}}}t")] texts = [t.text for t in root.iter(f"{{{W_NS}}}t")]
assert "My Title" in texts assert "My Title" in texts
@@ -44,13 +45,13 @@ def test_render_h1_has_bottom_border():
def test_render_h1_applies_style_heading_color(): def test_render_h1_applies_style_heading_color():
"""Heading color should come from STYLES[style]['heading_color'].""" """Heading color should come from STYLES[style]['heading_color'] (case-insensitive)."""
doc = Document() doc = Document()
style = STYLES["report"] style = STYLES["report"]
node = BeautifulSoup("<h1>Title</h1>", "html.parser").find("h1") node = BeautifulSoup("<h1>Title</h1>", "html.parser").find("h1")
_render_heading(doc, node, level=1, style=style) _render_heading(doc, node, level=1, style=style)
root = get_doc_xml(doc) root = get_doc_xml(doc)
colors = [c.get(f"{{{W_NS}}}val") for c in root.iter(f"{{{W_NS}}}color")] colors = [c.get(f"{{{W_NS}}}val").lower() for c in root.iter(f"{{{W_NS}}}color")]
assert "1e3a8a" in colors, f"expected heading color 1e3a8a from 'report' style, got {colors}" assert "1e3a8a" in colors, f"expected heading color 1e3a8a from 'report' style, got {colors}"