from pathlib import Path from typing import Callable import pytest from click.testing import CliRunner @pytest.fixture def cli_runner() -> CliRunner: """Click CLI runner.""" return CliRunner() @pytest.fixture def fake_mkdocs_yml(tmp_path: Path) -> Path: """Create a minimal mkdocs.yml file.""" yml = tmp_path / "mkdocs.yml" yml.write_text( """ site_name: Test Docs nav: [] plugins: - mkdocstrings """, encoding="utf-8", ) return yml @pytest.fixture def mock_mkdocs_load_config(monkeypatch): """Mock mkdocs.config.load_config.""" def fake_load_config(path): return object() # dummy config object monkeypatch.setattr( "mkdocs.config.load_config", fake_load_config, ) @pytest.fixture def mock_mkdocs_build(monkeypatch): called = {"value": False} def fake_build(config): called["value"] = True monkeypatch.setattr( "mkdocs.commands.build.build", fake_build, ) return lambda: called["value"] @pytest.fixture def mock_mkdocs_serve(monkeypatch): called = {"value": False} def fake_serve(*args, **kwargs): called["value"] = True monkeypatch.setattr( "mkdocs.commands.serve.serve", fake_serve, ) return lambda: called["value"]