Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.140s · 31.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.8s · import 0.124s · 32MB
30MB installed
● package 30MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CliRunner
✓ from click.testing import CliRunner
✗ from pytest_click import CliRunner
CliRunner is part of click.testing, not pytest-click
click
✓ import click
pytest-click does not re-export click
Minimal test using CliRunner from click.testing.
import click
from click.testing import CliRunner
@click.command()
def hello():
click.echo('Hello, World!')
def test_hello():
runner = CliRunner()
result = runner.invoke(hello, [])
assert result.exit_code == 0
assert 'Hello, World!' in result.output
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pytest_click'
Trying to import from pytest_click instead of click.testing.
fixInstall pytest-click: pip install pytest-click, then use `from click.testing import CliRunner`.
AttributeError: module 'click' has no attribute 'CliRunner'
Importing `CliRunner` from `click` instead of `click.testing`. Older Click versions might not have `click.testing`; ensure Click is installed.
fixInstall click: pip install click, then use `from click.testing import CliRunner`.
TypeError: invoke() missing 1 required positional argument: 'cli'
Calling `runner.invoke()` without passing the Click command object.
fixEnsure you pass the command as first argument: `runner.invoke(my_command, ['arg'])`.
Upgrade
Version history
1.1.0latest on PyPI · released Feb 11, 2022
Audit
Dependencies
pytestrequiredPlugin host