Coverage for tests/test_plugin.py: 100.00%

16 statements  

« prev     ^ index     » next       coverage.py v7.5.3, created at 2024-06-11 20:38 +0200

1"""Tests for the plugin module.""" 

2 

3import re 

4from pathlib import Path 

5 

6from mkdocs.commands.build import build 

7from mkdocs.config.base import load_config 

8 

9 

10def test_plugin() -> None: 

11 """Build our own documentation.""" 

12 config = load_config() 

13 config["plugins"].run_event("startup", command="build", dirty=False) 

14 try: 

15 build(config) 

16 finally: 

17 config["plugins"].run_event("shutdown") 

18 site_coverage_dir = Path(config["site_dir"]) / "coverage" 

19 for html_file in site_coverage_dir.iterdir(): 

20 if html_file.suffix == ".html" and html_file.name != "index.html" and "test" not in html_file.name: 

21 text = html_file.read_text() 

22 assert not re.search("covcovindex", text) 

23 assert not re.search('href="covindex.html"', text)