click_extra.tests package#
Submodules#
click_extra.tests.conftest module#
Fixtures, configuration and helpers for tests.
- click_extra.tests.conftest.skip_linux(*args, **kwargs) = MarkDecorator(mark=Mark(name='skipif', args=(True,), kwargs={'reason': 'Skip Linux'}))#
Pytest mark to skip a test if run on a Linux system.
- click_extra.tests.conftest.skip_macos(*args, **kwargs) = MarkDecorator(mark=Mark(name='skipif', args=(False,), kwargs={'reason': 'Skip macOS'}))#
Pytest mark to skip a test if run on a macOS system.
- click_extra.tests.conftest.skip_windows(*args, **kwargs) = MarkDecorator(mark=Mark(name='skipif', args=(False,), kwargs={'reason': 'Skip Windows'}))#
Pytest mark to skip a test if run on a Windows system.
- click_extra.tests.conftest.unless_linux(*args, **kwargs) = MarkDecorator(mark=Mark(name='skipif', args=(False,), kwargs={'reason': 'Linux required'}))#
Pytest mark to skip a test unless it is run on a Linux system.
- click_extra.tests.conftest.unless_macos(*args, **kwargs) = MarkDecorator(mark=Mark(name='skipif', args=(True,), kwargs={'reason': 'macOS required'}))#
Pytest mark to skip a test unless it is run on a macOS system.
- click_extra.tests.conftest.unless_windows(*args, **kwargs) = MarkDecorator(mark=Mark(name='skipif', args=(True,), kwargs={'reason': 'Windows required'}))#
Pytest mark to skip a test unless it is run on a Windows system.
- click_extra.tests.conftest.skip_windows_colors(*args, **kwargs) = MarkDecorator(mark=Mark(name='skipif', args=(False,), kwargs={'reason': 'Click overstrip colors on Windows'}))#
Skips color tests on Windows as
click.testing.invoke
overzealously strips colors.See: - https://github.com/pallets/click/issues/2111 - https://github.com/pallets/click/issues/2110
- click_extra.tests.conftest.invoke(extra_runner)[source]#
Invoke fixture shorthand for
click.testing.ExtraCliRunner.invoke
.
- click_extra.tests.conftest.command_decorators(no_commands=False, no_groups=False, no_click=False, no_cloup=False, no_redefined=False, no_extra=False, with_parenthesis=True, with_types=False)[source]#
Returns collection of Pytest parameters to test all forms of click/cloup/click- extra command-like decorators.
click_extra.tests.test_colorize module#
- click_extra.tests.test_colorize.test_theme_definition()[source]#
Ensure we do not leave any property we would have inherited from cloup and logging primitives.
- click_extra.tests.test_colorize.test_option_highlight(opt, expected_outputs)[source]#
Test highlighting of all option’s variations.
- click_extra.tests.test_colorize.test_standalone_color_option(invoke, option_decorator, param, expecting_colors)[source]#
Check color option values, defaults and effects on all things colored, including verbosity option.
- click_extra.tests.test_colorize.test_no_color_env_convention(invoke, env, env_expect_colors, param, param_expect_colors)[source]#
- click_extra.tests.test_colorize.test_integrated_color_option(invoke, param, expecting_colors)[source]#
Check effect of color option on all things colored, including verbosity option.
Also checks the color option in subcommands is inherited from parent context.
click_extra.tests.test_commands module#
Test defaults of our custom commands, as well as their customizations and attached options, and how they interact with each others.
- click_extra.tests.test_commands.all_command_cli(request)[source]#
A CLI that is mixing all variations and flavors of subcommands.
- click_extra.tests.test_commands.test_help_eagerness(invoke, all_command_cli, params)[source]#
See: https://click.palletsprojects.com/en/8.0.x/advanced/#callback-evaluation- order.
- click_extra.tests.test_commands.test_subcommand_help(invoke, all_command_cli, cmd_id, param)[source]#
- click_extra.tests.test_commands.test_colored_bare_help(invoke, cmd_decorator, param)[source]#
Extra decorators are always colored.
Even when stripped of their default parameters, as reported in: https://github.com/kdeldycke/click-extra/issues/534 https://github.com/kdeldycke/click-extra/pull/543
- click_extra.tests.test_commands.test_no_option_leaks_between_subcommands(invoke)[source]#
As reported in https://github.com/kdeldycke/click-extra/issues/489.
click_extra.tests.test_config module#
- click_extra.tests.test_config.test_strict_conf(invoke, create_config)[source]#
Same test as the one shown in the readme, but in strict validation mode.
- click_extra.tests.test_config.test_conf_file_overrides_defaults(invoke, simple_config_cli, create_config, httpserver, conf_name, conf_text, conf_data)[source]#
- click_extra.tests.test_config.test_auto_env_var_conf(invoke, simple_config_cli, create_config, httpserver, conf_name, conf_text, conf_data)[source]#
click_extra.tests.test_logging module#
- click_extra.tests.test_logging.test_root_logger_defaults()[source]#
Check our internal default is aligned to Python’s root logger.
- click_extra.tests.test_logging.test_unrecognized_verbosity(invoke, cmd_decorator, cmd_type)[source]#
- click_extra.tests.test_logging.test_default_root_logger(invoke, cmd_decorator, option_decorator, level)[source]#
Checks: - the default logger is
<root>
- the default logger message format - level names are colored - log level is propagated to all other loggers.
click_extra.tests.test_parameters module#
- click_extra.tests.test_parameters.test_show_auto_envvar_help(invoke, cmd_decorator, option_help)[source]#
Check that the auto-generated envvar appears in the help screen with the extra variants.
Checks that https://github.com/pallets/click/issues/2483 is addressed.
- click_extra.tests.test_parameters.test_auto_envvar_parsing(invoke, cmd_decorator, envvars, expected_flag)[source]#
This test highlights the way Click recognize and parse envvars.
It shows that the default behavior is not ideal, and covers how
extra_command
improves the situation by normalizing the envvar name.
- class click_extra.tests.test_parameters.Custom[source]#
Bases:
ParamType
A dummy custom type.
- name: str = 'Custom'#
the descriptive name of this type
- convert(value, param, ctx)[source]#
Convert the value to the correct type. This is not called if the value is
None
(the missing value).This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.
The
param
andctx
arguments may beNone
in certain situations, such as when converting prompt input.If the value cannot be converted, call
fail()
with a descriptive message.- Parameters:
value – The value to convert.
param – The parameter that is using this type to convert its value. May be
None
.ctx – The current context that arrived at this value. May be
None
.
- click_extra.tests.test_parameters.test_params_auto_types(invoke, option_decorator)[source]#
Check parameters types and structure are properly derived from CLI.
- click_extra.tests.test_parameters.test_standalone_show_params_option(invoke, cmd_decorator, option_decorator)[source]#
click_extra.tests.test_platforms module#
- click_extra.tests.test_platforms.test_mutual_exclusion()[source]#
Only directly tests OSes on which the test suite is running via GitHub actions.
- click_extra.tests.test_platforms.test_group_constants()[source]#
Group constants and IDs must be aligned.
- click_extra.tests.test_platforms.test_logical_grouping()[source]#
Test logical grouping of platforms.
- click_extra.tests.test_platforms.test_group_no_missing_platform()[source]#
Check all platform are attached to at least one group.
- click_extra.tests.test_platforms.test_non_overlapping_groups()[source]#
Check non-overlapping groups are mutually exclusive.
click_extra.tests.test_pygments module#
- click_extra.tests.test_pygments.is_relative_to(path, *other)[source]#
Return True if the path is relative to another path or False.
This is a backport of pathlib.Path.is_relative_to from Python 3.9.
- Return type:
- click_extra.tests.test_pygments.test_ansi_lexers_candidates(tmp_path)[source]#
Look into Pygments test suite to find all ANSI lexers candidates.
Good candidates for ANSI colorization are lexers that are producing
Generic.Output
tokens, which are often used by REPL-like and scripting terminal to render text in a console.The list is manually maintained in Click Extra code, and this test is here to detect new candidates from new releases of Pygments.
Attention
The Pygments source code is downloaded from GitHub in the form of an archive, and extracted in a temporary folder.
The version of Pygments used for this test is the one installed in the current environment.
Danger
Security check While extracting the archive, we double check we are not fed an archive exploiting relative
..
or.
path attacks.
- click_extra.tests.test_pygments.collect_classes(klass, prefix='Ansi')[source]#
Returns all classes defined in
click_extra.pygments
that are a subclass ofklass
, and whose name starts with the providedprefix
.
- click_extra.tests.test_pygments.get_pyproject_section(*section_path)[source]#
Descends into the TOML tree of
pyproject.toml
to reach the value specified bysection_path
.
click_extra.tests.test_tabulate module#
click_extra.tests.test_telemetry module#
click_extra.tests.test_testing module#
Test the testing utilities and the simulation of CLI execution.
- click_extra.tests.test_testing.test_real_fs()[source]#
Check a simple test is not caught into the CLI runner fixture which is encapsulating all filesystem access into temporary directory structure.
- click_extra.tests.test_testing.test_temporary_fs(extra_runner)[source]#
Check the CLI runner fixture properly encapsulated the filesystem in temporary directory.
click_extra.tests.test_timer module#
Test defaults of our custom commands, as well as their customizations and attached options, and how they interact with each others.
click_extra.tests.test_version module#
Test the --version
option.
Todo
Test standalone scripts setting package name to filename and version to None.
Todo
Test standalone script fetching version from __version__
variable.
- click_extra.tests.test_version.test_standalone_version_option(invoke, cmd_decorator, option_decorator)[source]#
- click_extra.tests.test_version.test_custom_message(invoke, cmd_decorator, message, regex_stdout)[source]#
- click_extra.tests.test_version.test_color_option_precedence(invoke)[source]#
–no-color has an effect on –version, if placed in the right order.
Eager parameters are evaluated in the order as they were provided on the command line by the user as expleined in: https://click.palletsprojects.com/en/8.0.x/advanced/#callback-evaluation-order
Todo
Maybe have the possibility to tweak CLI callback evaluation order so we can let the user to have the NO_COLOR env set to allow for color-less
--version
output.