Pytest

Important

For these helpers to work, you need to install click_extra’s additional dependencies from the pytest extra group:

$ pip install click_extra[pytest]

Utility functions

Todo

Write example and tutorial.

Fixtures

Todo

Write example and tutorial.

click_extra.pytest API

… py:module:: click_extra.pytest

Pytest fixtures and marks to help testing Click CLIs.

… py:function:: extra_runner()

module:

click_extra.pytest

Runner fixture for click.testing.ExtraCliRunner.

… py:function:: invoke(extra_runner)

module:

click_extra.pytest

Invoke fixture shorthand for click.testing.ExtraCliRunner.invoke.

… py:function:: command_decorators(no_commands=False, no_groups=False, no_click=False, no_cloup=False, no_extra=False, with_parenthesis=True, with_types=False)

module:

click_extra.pytest

Returns collection of Pytest parameters to test all command-like decorators.

Returns:

  • click.command

  • click.command()

  • cloup.command

  • cloup.command()

  • click_extra.command

  • click_extra.command()

  • click.group

  • click.group()

  • cloup.group

  • cloup.group()

  • click_extra.group

  • click_extra.group()

rtype:
sphinx_autodoc_typehints_type:

\:py\:class\:\tuple`\ \[:py:class:`~_pytest.mark.structures.ParameterSet`, :py:data:`…<Ellipsis>`]`

… py:function:: option_decorators(no_options=False, no_arguments=False, no_click=False, no_cloup=False, no_extra=False, with_parenthesis=True, with_types=False)

module:

click_extra.pytest

Returns collection of Pytest parameters to test all parameter-like decorators.

Returns:

  • click.option

  • click.option()

  • cloup.option

  • cloup.option()

  • click_extra.option

  • click_extra.option()

  • click.argument

  • click.argument()

  • cloup.argument

  • cloup.argument()

  • click_extra.argument

  • click_extra.argument()

rtype:
sphinx_autodoc_typehints_type:

\:py\:class\:\tuple`\ \[:py:class:`~_pytest.mark.structures.ParameterSet`, :py:data:`…<Ellipsis>`]`

… py:function:: create_config(tmp_path)

module:

click_extra.pytest

A generic fixture to produce a temporary configuration file.

… py:function:: assert_output_regex(request)

module:

click_extra.pytest

An assert-like utility for Pytest to compare CLI output against the regex.

Designed for the regexes defined above.