Coverage for tests/test_plugin.py: 100.00%
19 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-06 09:32 -0400
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-06 09:32 -0400
1"""Tests for the plugin module."""
3import re
4from pathlib import Path
6from mkdocs.commands.build import build
7from mkdocs.config.base import load_config
10def test_plugin() -> None:
11 """Build our own documentation."""
12 config = load_config()
13 config["plugins"]["iframe"].config["reports"] = [
14 {"name": name, "path": str(Path(__file__).parent / f"data/html{name}")}
15 for name in config["plugins"]["iframe"].config["reports"]
16 ]
17 config["plugins"].run_event("startup", command="build", dirty=False)
18 try:
19 build(config)
20 finally:
21 config["plugins"].run_event("shutdown")
23 for report in config["plugins"]["iframe"].config["reports"]:
24 name = report["name"]
25 site_report_dir = Path(config["site_dir"]) / name
26 for html_file in site_report_dir.iterdir():
27 if html_file.suffix == ".html" and html_file.name != "index.html" and "tests" not in html_file.name:
28 text = html_file.read_text()
29 assert not re.search(f"{name}{name}index", text)
30 assert not re.search('href="covindex.html"', text)