Skip to main content

pytest-click

Py.test plugin for Click.

Build Coverage Version Python versions License

Installation

The current stable release:

pip install pytest_click

Usage

pytest-click comes with some configurable fixtures - cli_runner and isolated_cli_runner.

import click


def test_cli(cli_runner):

    @click.command()
    @click.argument('name')
    def hello(name):
        click.echo('Hello %s!' % name)

    result = cli_runner.invoke(hello, ['Peter'])
    assert result.exit_code == 0
    assert result.output == 'Hello Peter!\n'
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 via 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 will be passed to click.testing.CliRunner initialization.

Metadata

Release files for pytest-click 1.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 1.0.0
File Size Uploaded Provenance Actions
pytest_click-1.0.0.tar.gz 3.3 kB Without provenance Details for pytest_click-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 7.3 kB

Release files / pytest_click-1.0.0.tar.gz

Download URL pytest_click-1.0.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
421155011a9b195acb75fc2f202db9b424ea24768f144f42e5af85519defd345
BLAKE2b-256 checksum
How to use checksums
334c824d78dd88fc88656e6a85034f17e006e74ef1a5812d2cc5bc2708eaef05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / pytest_click-1.0.0-py2.py3-none-any.whl

Download URL pytest_click-1.0.0-py2.py3-none-any.whl
Size 4.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c7705aca7a2c4f0b524ad5e7c700e30a9787ca6ce8d3608449447d14c16e36b8
BLAKE2b-256 checksum
How to use checksums
457be7b963f6ee73b92f5146c996275f815dc6bada0fb04f4f0f05dc8e90193b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Security for pytest-click 1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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