fix: ship the real DTD in the Pelican plugin
This commit is contained in:
parent
f54d350216
commit
884300f3cf
8 changed files with 483 additions and 74 deletions
|
|
@ -14,6 +14,12 @@ COPIES = {
|
|||
"mews-0.1.dtd": ROOT / "dtd" / "mews-0.1.dtd",
|
||||
}
|
||||
|
||||
# The Pelican plugin is a separate distributable package, so it carries its own
|
||||
# copy of the DTD rather than importing one. It shipped a hand-written
|
||||
# placeholder for a while, which silently stripped tables, ordered lists, forms
|
||||
# and the body variant class out of every page it produced.
|
||||
PLUGIN_DTD = ROOT / "pelican-mews" / "pelican" / "plugins" / "mews" / "dtd" / "mews.dtd"
|
||||
|
||||
|
||||
def test_packaged_copies_match_the_originals():
|
||||
for name, original in COPIES.items():
|
||||
|
|
@ -28,3 +34,10 @@ def test_the_spec_quotes_the_same_stylesheet():
|
|||
spec = (ROOT / "doc" / "SPEC.md").read_text()
|
||||
quoted = spec.split("```css\n", 1)[1].split("```", 1)[0]
|
||||
assert quoted.strip() == (ROOT / "mews-0.1.css").read_text().strip()
|
||||
|
||||
|
||||
def test_the_pelican_plugin_bundles_the_real_dtd():
|
||||
canonical = (ROOT / "dtd" / "mews-0.1.dtd").read_bytes()
|
||||
assert PLUGIN_DTD.read_bytes() == canonical, (
|
||||
f"{PLUGIN_DTD} differs from dtd/mews-0.1.dtd. Copy the original over it."
|
||||
)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,18 @@ def test_the_projects_own_pages_have_no_warnings_either(page):
|
|||
assert not report.warnings, "\n".join(str(f) for f in report.warnings)
|
||||
|
||||
|
||||
PLUGIN_PAGES = sorted(
|
||||
(ROOT / "pelican-mews" / "tests" / "fixtures").glob("*/expected.xhtml")
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("page", PLUGIN_PAGES, ids=lambda p: p.parent.name)
|
||||
def test_pages_the_pelican_plugin_produces_conform(page):
|
||||
"""What the plugin writes has to pass the validator, or it is no use."""
|
||||
report = validate_file(str(page))
|
||||
assert report.conforms, "\n".join(str(f) for f in report.failures)
|
||||
|
||||
|
||||
def test_the_dtd_still_matches_the_spec():
|
||||
"""dtd/check_dtd.py is hand-maintained; keep it running in CI."""
|
||||
result = subprocess.run(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue