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ΒΆ

Pytest fixtures and marks to help testing Click CLIs.

click_extra.pytest.extra_runner()[source]ΒΆ

Runner fixture for click.testing.ExtraCliRunner.

click_extra.pytest.invoke(extra_runner)[source]ΒΆ

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

click_extra.pytest.skip_naked(*args, **kwargs) = MarkDecorator(mark=Mark(name='skip', args=(), kwargs={'reason': 'Naked decorator not supported.'}))ΒΆ

Mark to skip Cloup decorators without parenthesis.

click_extra.pytest.command_decorators(no_commands=False, no_groups=False, no_click=False, no_cloup=False, no_extra=False, with_parenthesis=True, with_types=False)[source]ΒΆ

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()

Return type:

tuple[ParameterSet, ...]

click_extra.pytest.option_decorators(no_options=False, no_arguments=False, no_click=False, no_cloup=False, no_extra=False, with_parenthesis=True, with_types=False)[source]ΒΆ

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()

Return type:

tuple[ParameterSet, ...]

click_extra.pytest.create_config(tmp_path)[source]ΒΆ

A generic fixture to produce a temporary configuration file.

click_extra.pytest.assert_output_regex(request)[source]ΒΆ

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

Designed for the regexes defined above.