From efb1bc3a0bdae0aa4dd0b4a7e7885a4f99805bf8 Mon Sep 17 00:00:00 2001 From: Kim Christie Date: Wed, 7 Oct 2026 10:15:50 +0100 Subject: [PATCH] Test suite --- pyproject.toml | 9 +++++++-- src/mkdocs/__init__.py | 4 ++-- src/mkdocs/mkdocs.py | 6 +++--- tests/test_mkdocs.py | 18 +++++++++++++++++- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bfcffac..8001ac8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ "Topic :: Internet :: WWW/HTTP", ] dependencies = [ - "httpx>=1.0.dev6", + "httpx", "click", "jinja2", "markdown", @@ -33,5 +33,10 @@ dynamic = ["version"] [tool.hatch.version] path = "src/mkdocs/__version__.py" +[dependency-groups] +dev = [ + "pytest", +] + [project.scripts] -mkdocs = "mkdocs:cli" +mkdocs = "mkdocs:mkdocs" diff --git a/src/mkdocs/__init__.py b/src/mkdocs/__init__.py index 3e7b875..fbd1cb2 100644 --- a/src/mkdocs/__init__.py +++ b/src/mkdocs/__init__.py @@ -1,5 +1,5 @@ from .__version__ import __title__, __version__ -from .mkdocs import get_current_page, get_site, link_to, Page, Static, Site, MkDocs, cli +from .mkdocs import get_current_page, get_site, link_to, Page, Static, Site, MkDocs, mkdocs __all__ = [ @@ -12,5 +12,5 @@ 'Static', 'Site', 'MkDocs', - 'cli', + 'mkdocs', ] diff --git a/src/mkdocs/mkdocs.py b/src/mkdocs/mkdocs.py index 86e13b3..8e19f04 100644 --- a/src/mkdocs/mkdocs.py +++ b/src/mkdocs/mkdocs.py @@ -310,12 +310,12 @@ def app(request): # Command line client... @click.group() -def cli(): +def mkdocs(): if pathlib.Path('mkdocs.yml').exists(): raise Exception('Found mkdocs.yml config, but mkdocs 2.0 pre-release is installed') -@cli.command() +@mkdocs.command() @click.option('--dir', default='docs', help="Default 'docs'.", type=click.Path(exists=True, file_okay=False, dir_okay=True)) @click.option('--output', default='site', help="Default 'site'.", type=click.Path(file_okay=False, dir_okay=True)) def build(dir, output): @@ -323,7 +323,7 @@ def build(dir, output): m.build(dir, output) -@cli.command() +@mkdocs.command() @click.option('--dir', default='docs', help="Default 'docs'.", type=click.Path(exists=True, file_okay=False, dir_okay=True)) def serve(dir): m = MkDocs(dir) diff --git a/tests/test_mkdocs.py b/tests/test_mkdocs.py index 312c833..c9cceba 100644 --- a/tests/test_mkdocs.py +++ b/tests/test_mkdocs.py @@ -1,2 +1,18 @@ +from click.testing import CliRunner +import mkdocs + + def test_mkdocs(): - pass + runner = CliRunner() + result = runner.invoke(mkdocs.mkdocs, ['--help']) + assert result.exit_code == 0 + assert result.output == ( + 'Usage: mkdocs [OPTIONS] COMMAND [ARGS]...\n' + '\n' + 'Options:\n' + ' --help Show this message and exit.\n' + '\n' + 'Commands:\n' + ' build\n' + ' serve\n' + )