test(md2doc): fix pStyle attribute + case-insensitive color compare
This commit is contained in:
@@ -27,8 +27,9 @@ def test_render_h1_uses_heading1_style_and_text():
|
||||
node = BeautifulSoup("<h1>My Title</h1>", "html.parser").find("h1")
|
||||
_render_heading(doc, node, level=1, style=style)
|
||||
root = get_doc_xml(doc)
|
||||
pStyles = [p.text for p in root.iter(f"{{{W_NS}}}pStyle")]
|
||||
assert "Heading1" in pStyles
|
||||
# pStyle is an attribute, not text content
|
||||
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")]
|
||||
assert "My Title" in texts
|
||||
|
||||
@@ -44,13 +45,13 @@ def test_render_h1_has_bottom_border():
|
||||
|
||||
|
||||
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()
|
||||
style = STYLES["report"]
|
||||
node = BeautifulSoup("<h1>Title</h1>", "html.parser").find("h1")
|
||||
_render_heading(doc, node, level=1, style=style)
|
||||
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}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user