Skip to content

Commit f8aa9d2

Browse files
committed
parametrize unit tests for basic sites
1 parent 22fbb0e commit f8aa9d2

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

tests/basic_setup/mkdocs_w_macros.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ use_directory_urls: true
33

44
plugins:
55
- search
6-
# - macros
7-
- git-authors
6+
- git-authors
7+
- macros
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
site_name: test gitauthors_plugin
2+
use_directory_urls: true
3+
4+
plugins:
5+
- search
6+
- macros
7+
- git-authors

tests/test_basic.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import re
2020
import shutil
2121
import os
22+
import pytest
23+
2224
from click.testing import CliRunner
2325
from mkdocs.__main__ import build_command
2426
from git import Repo
@@ -54,29 +56,16 @@ def build_docs_setup(mkdocs_path, output_path):
5456
build_command, ["--config-file", mkdocs_path, "--site-dir", str(output_path)]
5557
)
5658

57-
58-
def test_basic_working(tmp_path):
59-
60-
result = build_docs_setup("tests/basic_setup/mkdocs.yml", tmp_path)
61-
assert result.exit_code == 0, (
62-
"'mkdocs build' command failed. Error: %s" % result.stdout
63-
)
64-
65-
index_file = tmp_path / "index.html"
66-
assert index_file.exists(), "%s does not exist" % index_file
67-
68-
contents = index_file.read_text()
69-
assert re.search("<span class='git-page-authors", contents)
70-
assert re.search("<li><a href='mailto:[email protected]'>Tim Vink</a></li>", contents)
71-
72-
73-
def test_basic_working_macros(tmp_path):
59+
@pytest.mark.parametrize(
60+
"mkdocs_file",
61+
["mkdocs.yml", "mkdocs_w_macros.yml", "mkdocs_w_macros2.yml", "mkdocs_complete_material.yml"],
62+
)
63+
def test_basic_working(tmp_path, mkdocs_file):
7464
"""
7565
combination with mkdocs-macros-plugin lead to error.
76-
7766
See https://github.com/timvink/mkdocs-git-authors-plugin/issues/60
7867
"""
79-
result = build_docs_setup("tests/basic_setup/mkdocs_w_macros.yml", tmp_path)
68+
result = build_docs_setup("tests/basic_setup/mkdocs.yml", tmp_path)
8069
assert result.exit_code == 0, (
8170
"'mkdocs build' command failed. Error: %s" % result.stdout
8271
)
@@ -89,6 +78,7 @@ def test_basic_working_macros(tmp_path):
8978
assert re.search("<li><a href='mailto:[email protected]'>Tim Vink</a></li>", contents)
9079

9180

81+
9282
def test_exclude_working(tmp_path):
9383

9484
result = build_docs_setup("tests/basic_setup/mkdocs_exclude.yml", tmp_path)

0 commit comments

Comments
 (0)