File: test_loader.py

package info (click to toggle)
mkdocs-click 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: python: 715; sh: 17; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 864 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under the Apache license (see LICENSE)
from contextlib import nullcontext

import pytest

from mkdocs_click._exceptions import MkDocsClickException
from mkdocs_click._loader import load_command


@pytest.mark.parametrize(
    "module, command, exc",
    [
        pytest.param("tests.app.cli", "cli", None, id="ok"),
        pytest.param(
            "tests.app.cli", "doesnotexist", MkDocsClickException, id="command-does-not-exist"
        ),
        pytest.param("doesnotexist", "cli", ImportError, id="module-does-not-exist"),
        pytest.param("tests.app.cli", "NOT_A_COMMAND", MkDocsClickException, id="not-a-command"),
    ],
)
def test_load_command(module: str, command: str, exc):
    with pytest.raises(exc) if exc is not None else nullcontext():
        load_command(module, command)