Skip to main content

pytest-click

Build Coverage Version Python versions License

pytest plugin for Click.

Installation

pip install pytest-click

Usage

pytest-click comes with two fixtures: cli_runner and isolated_cli_runner.

import click


def test_cli(cli_runner):
    @click.command()
    @click.argument("name")
    def hello(name):
        click.echo(f"Hello {name}!")

    result = cli_runner.invoke(hello, ["Peter"])
    assert result.exit_code == 0
    assert result.output == "Hello Peter!\n"

isolated_cli_runner runs each test inside CliRunner.isolated_filesystem():

import click


def test_fixture(isolated_cli_runner):
    @click.command()
    @click.argument("f", type=click.File())
    def cat(f):
        click.echo(f.read())

    with open("hello.txt", "w") as f:
        f.write("Hello World!")

    result = isolated_cli_runner.invoke(cat, ["hello.txt"])
    assert result.exit_code == 0
    assert result.output == "Hello World!\n"

Both runners can be configured with the runner_setup mark:

import pytest


@pytest.mark.runner_setup(charset="cp1251", env={"test": 1}, echo_stdin=True)
def test_runner_setup(cli_runner): ...

All kwargs are passed to click.testing.CliRunner.

Metadata

Release files for pytest-click 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-click 2.0.0
File Size Uploaded Provenance Actions
pytest_click-2.0.0.tar.gz 4.5 kB With provenance Details for pytest_click-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-click 2.0.0
File Interpreter ABI Platform Actions
pytest_click-2.0.0-py3-none-any.whl Python 3 none any Details for pytest_click-2.0.0-py3-none-any.whl

Total release size: 8.6 kB

Release files / pytest_click-2.0.0.tar.gz

Download URL pytest_click-2.0.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
12e314617a3d88b416d48d5afb869da75992dc08bed948d6214fff921b26daf6
BLAKE2b-256 checksum
How to use checksums
39b2fd10c79e1c64327cc4ffed580d53ce35f7bf78a8130ded112239d5e8b5d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / pytest_click-2.0.0-py3-none-any.whl

Download URL pytest_click-2.0.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdc69f40139de0476feac420f450c84eac8a5ad182ce467d661f7dcaf303656b
BLAKE2b-256 checksum
How to use checksums
006e16f8f240fb15e5c29b0b97e8272f9ac8104f8f85e0451f269195e7eceef6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for pytest-click 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_click-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page