Skip to content
Myr

test__detect_program_name.py

This file

Path

tests/test_utils/test__detect_program_name.py

27 lines · 762 bytes · Python

Last changed by

Add files for _detect_program_name, _expand_args, and make_default_short_help.Edward Gbefore adoption47cc96f

History of this file

Take it

1import pathlib23import pytest45import click678class MockMain:9    __slots__ = "__package__"1011    def __init__(self, package_name):12        self.__package__ = package_name131415@pytest.mark.parametrize(16    ("path", "main", "expected"),17    [18        ("example.py", None, "example.py"),19        (str(pathlib.Path("/foo/bar/example.py")), None, "example.py"),20        ("example", None, "example"),21        (str(pathlib.Path("example/__main__.py")), "example", "python -m example"),22        (str(pathlib.Path("example/cli.py")), "example", "python -m example.cli"),23        (str(pathlib.Path("./example")), "", "example"),24    ],25)26def test_detect_program_name(path, main, expected):27    assert click.utils._detect_program_name(path, _main=MockMain(main)) == expected