"""The project's own pages. Every one of them has to follow the spec.""" from pathlib import Path import subprocess import sys import pytest from mews.lint import validate_file ROOT = Path(__file__).resolve().parent.parent PAGES = [*sorted((ROOT / "site").glob("*.html")), ROOT / "sample" / "sample.html"] @pytest.mark.parametrize("page", PAGES, ids=lambda p: p.name) def test_the_projects_own_pages_conform(page): report = validate_file(str(page)) assert report.conforms, "\n".join(str(f) for f in report.failures) @pytest.mark.parametrize("page", PAGES, ids=lambda p: p.name) def test_the_projects_own_pages_have_no_warnings_either(page): report = validate_file(str(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( [sys.executable, str(ROOT / "dtd" / "check_dtd.py")], capture_output=True, text=True, check=False, ) assert result.returncode == 0, result.stderr