tests packageΒΆ
SubmodulesΒΆ
tests.conftest moduleΒΆ
Fixtures, configuration and helpers for tests.
- class tests.conftest.FormatType(*values)[source]ΒΆ
Bases:
EnumSphinx document format types and their file extensions.
- RST = '.rst'ΒΆ
- MYST = '.md'ΒΆ
- class tests.conftest.SphinxAppWrapper(app, format_type)[source]ΒΆ
Bases:
objectWrapper around Sphinx application with additional testing methods.
- classmethod create(format_type, tmp_path, return_srcdir=False)[source]ΒΆ
Factory method to create a SphinxAppWrapper with given format.
- Return type:
Generator[SphinxAppWrapper|tuple[SphinxAppWrapper,Path],None,None]
- tests.conftest.sphinx_app_rst(tmp_path)[source]ΒΆ
Create a Sphinx application for testing RST format only.
- tests.conftest.sphinx_app_myst(tmp_path)[source]ΒΆ
Create a Sphinx application for testing MyST format only.
- tests.conftest.sphinx_app_myst_with_include(tmp_path)[source]ΒΆ
Create a Sphinx application for testing MyST format with include files.
- class tests.conftest.DirectiveTestCase(name, format_type=None, source_block=None, run_block=None, document=None, html_matches=None)[source]ΒΆ
Bases:
objectTest case data for directive tests.
- format_type: FormatType | None = NoneΒΆ
tests.test_colorize moduleΒΆ
- tests.test_colorize.test_theme_definition()[source]ΒΆ
Ensure we do not leave any property we would have inherited from cloup and logging primitives.
- tests.test_colorize.test_option_highlight(opt, expected_outputs)[source]ΒΆ
Test highlighting of all optionβs variations.
Ensure hidden options are not highlighted.
- tests.test_colorize.test_standalone_color_option(invoke, option_decorator, param, expecting_colors, assert_output_regex)[source]ΒΆ
Check color option values, defaults and effects on all things colored, including verbosity option.
- tests.test_colorize.test_no_color_env_convention(invoke, env, env_expect_colors, param, param_expect_colors)[source]ΒΆ
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.
- tests.test_commands.test_module_root_declarations()[source]ΒΆ
Verify
click_extra.__all__is a superset of click and cloup.Sort order is enforced by
ruff(RUF022).
- tests.test_commands.all_command_cli()[source]ΒΆ
A CLI that is mixing all variations and flavors of subcommands.
- tests.test_commands.test_group_help(invoke, all_command_cli, param, exit_code, assert_output_regex)[source]ΒΆ
- tests.test_commands.test_help_eagerness(invoke, all_command_cli, params, exit_code, expect_help, expect_empty_stderr, assert_output_regex)[source]ΒΆ
See: https://click.palletsprojects.com/en/stable/click-concepts/#callback-evaluation-order
- tests.test_commands.test_help_custom_name(invoke)[source]ΒΆ
Removes the
-hshort option as we reserve it for a custom-h/--headeroption.See: https://github.com/kdeldycke/mail-deduplicate/issues/762
- tests.test_commands.test_subcommand_help(invoke, all_command_cli, cmd_id, param, assert_output_regex)[source]ΒΆ
- 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
- tests.test_commands.test_duplicate_option(invoke)[source]ΒΆ
See: - https://kdeldycke.github.io/click-extra/commands.html#change-default-options - https://github.com/kdeldycke/click-extra/issues/232
- tests.test_commands.test_no_option_leaks_between_subcommands(invoke, assert_output_regex)[source]ΒΆ
As reported in https://github.com/kdeldycke/click-extra/issues/489.
- tests.test_commands.test_show_envvar_parameter(invoke, cmd_decorator, ctx_settings, expected_help)[source]ΒΆ
- tests.test_commands.test_raw_args(invoke)[source]ΒΆ
Raw args are expected to be scoped in subcommands.
- tests.test_commands.test_lazy_group(invoke, tmp_path, lazy_cmd_decorator, lazy_group_decorator)[source]ΒΆ
Test extends the snippet from Click documentation.
tests.test_config moduleΒΆ
- tests.test_config.test_unset_conf_debug_message(invoke, simple_config_cli, assert_output_regex)[source]ΒΆ
- tests.test_config.test_conf_unparsable(invoke, simple_config_cli, create_config)[source]ΒΆ
Explicit βconfig pointing to a file with garbage content.
- tests.test_config.test_conf_empty_file(invoke, simple_config_cli, create_config)[source]ΒΆ
Explicit βconfig pointing to an empty file.
- tests.test_config.test_standalone_no_config_option(invoke)[source]ΒΆ
@no_config_option cannot work without @config_option.
- tests.test_config.test_strict_conf(invoke, create_config, conf_text, expect_error)[source]ΒΆ
Strict mode rejects unknown params but accepts clean configs.
- tests.test_config.test_conf_file_overrides_defaults(invoke, simple_config_cli, create_config, httpserver, conf_name, conf_text, conf_data, assert_output_regex)[source]ΒΆ
- tests.test_config.test_auto_envvar_conf(invoke, simple_config_cli, create_config, httpserver, conf_name, conf_text, conf_data)[source]ΒΆ
- tests.test_config.test_conf_file_overridden_by_cli_param(invoke, simple_config_cli, create_config, httpserver, conf_name, conf_text, conf_data)[source]ΒΆ
- tests.test_config.test_conf_metadata(invoke, create_config, httpserver, conf_name, conf_text, conf_data)[source]ΒΆ
- tests.test_config.test_conf_metadata_no_config(invoke)[source]ΒΆ
ctx.meta entries are not set when βno-config skips loading.
- tests.test_config.test_default_map_populated(invoke, create_config)[source]ΒΆ
Verify default_map structure when config values match CLI parameters.
Complements test_conf_metadata which only checks the empty default_map case (where no config values match the CLIβs parameter structure).
- tests.test_config.test_default_map_none_without_config(invoke)[source]ΒΆ
Verify default_map is left alone when βno-config is used.
- tests.test_config.test_nested_subcommand_config(invoke, create_config)[source]ΒΆ
Config propagates through group -> subgroup -> leaf command.
Two CLIs sharing the same configuration file.
- tests.test_config.test_lazy_group_config(invoke, create_config, tmp_path)[source]ΒΆ
Test that lazy groups work with config files.
- tests.test_config.test_lazy_group_config_no_config_flag(invoke, create_config, tmp_path)[source]ΒΆ
Test that βno-config works with lazy groups.
- tests.test_config.test_file_pattern(file_format_patterns, expected_pattern)[source]ΒΆ
Test the file_pattern property with different file format configurations.
- tests.test_config.test_default_pattern_roaming_force_posix(roaming, force_posix, current_platform, expected_path, monkeypatch)[source]ΒΆ
Test that roaming and force_posix affect the default pattern generation.
- tests.test_config.test_default_pattern_xdg_config_home(force_posix, tmp_path, monkeypatch)[source]ΒΆ
Test that default_pattern respects XDG_CONFIG_HOME on Linux.
- tests.test_config.test_parent_patterns(tmp_path, search_parents, subdirs, create_file, expected_start)[source]ΒΆ
- tests.test_config.test_parent_patterns_with_magic_pattern(tmp_path, pattern_factory, expected_factory)[source]ΒΆ
Test parent_patterns with glob patterns containing magic characters.
- tests.test_config.test_parent_patterns_magic_no_search(tmp_path)[source]ΒΆ
Magic pattern with search_parents=False yields only the original.
- tests.test_config.test_parent_patterns_relative_path(tmp_path)[source]ΒΆ
Test parent_patterns resolves relative paths to absolute.
- tests.test_config.test_parent_patterns_stop_at_path(tmp_path)[source]ΒΆ
stop_at as a path limits the parent directory walk.
- tests.test_config.test_parent_patterns_stop_at_vcs(tmp_path, has_vcs, expected_bounded)[source]ΒΆ
stop_at=VCS stops at VCS root, or walks to filesystem root if none.
- tests.test_config.test_parent_patterns_inaccessible_directory(tmp_path)[source]ΒΆ
Walk stops at an inaccessible directory.
- tests.test_config.test_find_vcs_root(tmp_path, vcs_dir, expected)[source]ΒΆ
Test _find_vcs_root with .git, .hg, and no VCS markers.
- tests.test_config.test_config_option_default_no_config(invoke, create_config)[source]ΒΆ
ConfigOption with default=NO_CONFIG disables autodiscovery.
- tests.test_config.test_no_config_explicit_with_default_no_config(invoke)[source]ΒΆ
βno-config still prints the skip message even when NO_CONFIG is the default.
- tests.test_config.test_excluded_params(invoke, create_config)[source]ΒΆ
Custom excluded_params prevents config values from being applied.
- tests.test_config.test_included_params(invoke, create_config)[source]ΒΆ
Only parameters in included_params are loaded from config.
- tests.test_config.test_included_params_empty(invoke, create_config)[source]ΒΆ
An empty included_params excludes all params from config.
- tests.test_config.test_included_and_excluded_params_conflict()[source]ΒΆ
Providing both included_params and excluded_params raises ValueError.
- tests.test_config.test_multiple_files_matching_glob(invoke, create_config, tmp_path)[source]ΒΆ
When multiple files match a glob, only the first parseable one is used.
- tests.test_config.test_forced_flags_warnings(caplog)[source]ΒΆ
Warnings fire when SPLIT, BRACE or NODIR flags are missing.
- tests.test_config.test_brace_multi_format_search(invoke, tmp_path, ext)[source]ΒΆ
All format extensions are found in the search directory.
Regression test: before BRACE expansion, only the first format in the default pattern got the directory prefix β others were searched in CWD.
- tests.test_config.test_root_dir_parent_search_finds_non_toml(invoke, tmp_path)[source]ΒΆ
Parent search with root_dir correctly finds non-TOML config in parents.
Before the root_dir refactoring, SPLIT patterns like
*.toml|*.yamlonly applied the directory prefix to the first sub-pattern. Now with root_dir, all sub-patterns are scoped to the correct directory.
- tests.test_config.test_no_enabled_formats_raises()[source]ΒΆ
ValueError raised when all formats are disabled.
- tests.test_config.test_pyproject_toml_in_defaults()[source]ΒΆ
ConfigOption() with default file_format_patterns includes PYPROJECT_TOML.
- tests.test_config.test_pyproject_toml_tool_extraction(simple_config_cli)[source]ΒΆ
parse_conf with PYPROJECT_TOML returns the [tool] subsection.
- tests.test_config.test_pyproject_toml_no_tool_section(simple_config_cli)[source]ΒΆ
pyproject.toml without [tool] returns empty dict.
- tests.test_config.test_file_pattern_with_pyproject_toml()[source]ΒΆ
Explicit file_format_patterns with PYPROJECT_TOML works.
- tests.test_config.test_pyproject_toml_overrides_defaults(invoke, create_config)[source]ΒΆ
End-to-end: a CLI with default formats reads from pyproject.toml.
- tests.test_config.test_validate_config_valid(invoke, create_config)[source]ΒΆ
βvalidate-config with a valid config file exits 0.
- tests.test_config.test_validate_config_invalid_keys(invoke, create_config)[source]ΒΆ
βvalidate-config with unrecognized keys exits 1.
- tests.test_config.test_extensionless_config(invoke, create_config, default_pattern, expected_help_default)[source]ΒΆ
Both broad and exact default patterns resolve the same .commandrc file.
The
defaultparameter is printed as-is on the help screen, so an exact path is more informative than a broad glob, but both locate the same file.
- tests.test_config.test_validate_config_unparsable(invoke, create_config)[source]ΒΆ
βvalidate-config with garbage content exits 2.
- tests.test_config.test_validate_config_missing_file(invoke, tmp_path)[source]ΒΆ
βvalidate-config with a nonexistent file is caught by Clickβs Path(exists=True).
- tests.test_config.test_validate_config_requires_config_option(invoke, tmp_path)[source]ΒΆ
βvalidate-config without @config_option raises RuntimeError.
- tests.test_config.test_validate_config_pyproject_toml(invoke, create_config)[source]ΒΆ
βvalidate-config works with pyproject.toml [tool.*] sections.
- tests.test_config.test_default_subcommand_selection(invoke, create_config, cli_subcmd, expected, unexpected)[source]ΒΆ
Config default is used when no subcommand given; CLI wins otherwise.
- tests.test_config.test_default_subcommand_chained(invoke, create_config)[source]ΒΆ
chain=True group runs multiple config-listed subcommands in order.
- tests.test_config.test_default_subcommand_config_errors(invoke, create_config, conf_value, error_fragment)[source]ΒΆ
Bad _default_subcommands values produce clear errors.
- tests.test_config.test_default_subcommand_strict_mode_tolerance(invoke, create_config)[source]ΒΆ
strict=True config with _default_subcommands doesnβt raise.
- tests.test_config.test_default_subcommand_validate_config_tolerance(invoke, create_config)[source]ΒΆ
βvalidate-config with _default_subcommands reports valid.
- tests.test_config.test_default_subcommand_with_options(invoke, create_config)[source]ΒΆ
Default subcommand receives its config-provided options.
- tests.test_config.test_default_subcommand_no_config(invoke)[source]ΒΆ
Normal behavior when no config file is loaded.
- tests.test_config.test_default_subcommand_duplicates_warning(invoke, create_config)[source]ΒΆ
Duplicate entries in _default_subcommands are deduplicated with a warning.
- tests.test_config.test_default_subcommand_cli_override_debug_log(invoke, create_config)[source]ΒΆ
Debug log emitted when CLI subcommands override config defaults.
- tests.test_config.test_prepend_subcommand_selection(invoke, create_config, cli_subcmd, expected, unexpected)[source]ΒΆ
Prepend fires regardless of whether a CLI subcommand is given.
- tests.test_config.test_prepend_subcommand_with_defaults(invoke, create_config, cli_subcmd, expect_backup)[source]ΒΆ
Prepend always applies; defaults only fire when no CLI subcommand given.
- tests.test_config.test_prepend_subcommand_non_chained_error(invoke, create_config)[source]ΒΆ
Error on non-chained group.
- tests.test_config.test_prepend_subcommand_config_errors(invoke, create_config, conf_value, error_fragment)[source]ΒΆ
Bad _prepend_subcommands values produce clear errors.
- tests.test_config.test_prepend_subcommand_strict_mode_tolerance(invoke, create_config)[source]ΒΆ
strict=True config with _prepend_subcommands doesnβt raise.
- tests.test_config.test_prepend_subcommand_validate_config_tolerance(invoke, create_config)[source]ΒΆ
βvalidate-config with _prepend_subcommands reports valid.
- tests.test_config.test_prepend_subcommand_duplicates_warning(invoke, create_config)[source]ΒΆ
Duplicate entries in _prepend_subcommands are deduplicated with a warning.
- tests.test_config.test_prepend_subcommand_info_log(invoke, create_config)[source]ΒΆ
INFO log emitted when _prepend_subcommands are injected.
- tests.test_config.test_prepend_subcommand_multiple(invoke, create_config)[source]ΒΆ
Multiple prepend subcommands run in order.
- tests.test_config.test_sanity_broad_glob_narrow_format(caplog)[source]ΒΆ
Broad glob + all-literal format patterns triggers a debug log.
- tests.test_config.test_sanity_broad_glob_wildcard_format(caplog)[source]ΒΆ
Broad glob + wildcard format patterns does NOT trigger the warning.
- tests.test_config.test_sanity_disjoint_patterns(caplog)[source]ΒΆ
Literal default not matching any format pattern triggers a debug log.
- tests.test_config.test_sanity_disjoint_matching_literal(caplog)[source]ΒΆ
Literal default matching a format pattern does NOT trigger the warning.
- tests.test_config.test_sanity_format_extension_mismatch(caplog)[source]ΒΆ
Format pattern extension mismatching its format triggers a debug log.
- tests.test_config.test_sanity_format_extension_correct(caplog)[source]ΒΆ
Correctly-matched format extension does NOT trigger the warning.
- tests.test_config.test_sanity_dotfile_without_dotglob(caplog)[source]ΒΆ
Dotfile in default without DOTGLOB triggers a debug log.
- tests.test_config.test_sanity_dotfile_format_without_dotglob(caplog)[source]ΒΆ
Dotfile in format patterns without DOTGLOB triggers a debug log.
- tests.test_config.test_sanity_dotfile_with_dotglob(caplog)[source]ΒΆ
Dotfile with DOTGLOB does NOT trigger the warning.
- tests.test_config.test_sanity_no_explicit_default(caplog)[source]ΒΆ
Without an explicit string default, checks 1/2/4 are skipped.
- tests.test_config.test_sanity_format_mismatch_without_explicit_default(caplog)[source]ΒΆ
Check 3 (format mismatch) runs even without explicit default.
- tests.test_config.test_dotted_keys_in_config(invoke, simple_config_cli, create_config, conf_name, conf_text)[source]ΒΆ
Dotted keys in config files are expanded into nested structures.
- tests.test_config.test_expand_dotted_keys_conflict_warning(caplog, input_conf, warning_fragment)[source]ΒΆ
Scalar/dict conflicts on the same key emit a warning.
- tests.test_config.test_expand_dotted_keys_empty_segments(caplog, input_conf)[source]ΒΆ
Dotted keys with empty segments are skipped with a warning.
- tests.test_config.test_expand_dotted_keys_strict_conflict(input_conf, error_fragment)[source]ΒΆ
Strict mode raises ValueError on type conflicts.
- tests.test_config.test_expand_dotted_keys_strict_empty_segments(input_conf)[source]ΒΆ
Strict mode raises ValueError on dotted keys with empty segments.
- tests.test_config.test_strict_conf_dotted_key_conflict(invoke, create_config)[source]ΒΆ
Strict mode rejects configs with dotted-key type conflicts.
- tests.test_config.test_config_schema_dataclass(invoke, create_config)[source]ΒΆ
Dataclass schemas are auto-detected and instantiated with normalized keys.
- tests.test_config.test_config_schema_callable(invoke, create_config)[source]ΒΆ
A plain callable can be used as config_schema.
- tests.test_config.test_config_schema_no_config_file(invoke)[source]ΒΆ
When no config file is found, tool_config is not set.
- tests.test_config.test_config_schema_dataclass_defaults(invoke, create_config)[source]ΒΆ
Dataclass defaults are used for fields not present in the config file.
- tests.test_config.test_fallback_sections(invoke, create_config)[source]ΒΆ
Legacy section names are recognized with a deprecation warning.
- tests.test_config.test_fallback_sections_prefers_current(invoke, create_config)[source]ΒΆ
When both current and legacy sections exist, current wins.
- tests.test_config.test_config_schema_multiple_formats(invoke, create_config, conf_name, conf_text)[source]ΒΆ
Config schema works with YAML and JSON, not just TOML.
tests.test_envvar moduleΒΆ
- tests.test_envvar.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.
tests.test_logging moduleΒΆ
- tests.test_logging.test_root_logger_defaults()[source]ΒΆ
Check our internal default is aligned to Pythonβs root logger.
- tests.test_logging.test_integrated_verbosity_options(invoke, args, expected_level, assert_output_regex)[source]ΒΆ
- tests.test_logging.test_standalone_option_default_logger(invoke, cmd_decorator, option_decorator, args, expected_level, assert_output_regex)[source]ΒΆ
Checks: - option affect log level - the default logger is
root- the default logger message format - level names are colored - log level is propagated to all other loggers
- tests.test_logging.test_default_logger_param(invoke, logger_param, params)[source]ΒΆ
Passing a logger instance or name to the
default_loggerparameter works.
- tests.test_logging.test_new_extra_logger_name_passing(invoke)[source]ΒΆ
Test extra logger with custom format, passed to the option by its name.
- tests.test_logging.test_new_extra_logger_object_passing(invoke)[source]ΒΆ
Test extra logger with custom format, passed as an object to the option.
tests.test_parameters moduleΒΆ
- class tests.test_parameters.Custom[source]ΒΆ
Bases:
ParamTypeA dummy custom 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
paramandctxarguments may beNonein 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.
- tests.test_parameters.test_params_auto_types(invoke, option_decorator)[source]ΒΆ
Check parameters types and structure are properly derived from CLI.
- tests.test_parameters.assert_table_content(output, expected_table, table_format=None)[source]ΒΆ
Helper to assert the content of a rendered table in the output.
- Return type:
- tests.test_parameters.test_standalone_show_params_option(invoke, cmd_decorator, option_decorator, assert_output_regex)[source]ΒΆ
- tests.test_parameters.test_show_params_table_format_ordering(invoke, args_order)[source]ΒΆ
--show-paramsrespects--table-formatregardless of CLI order.
- tests.test_parameters.test_show_params_native_types(invoke, table_format)[source]ΒΆ
Serialization formats emit native types instead of styled glyphs.
- tests.test_parameters.test_subcommand_conflicts_with_parent_param(invoke)[source]ΒΆ
A subcommand whose name matches its direct parentβs param is a real conflict.
In a config file, the key would be ambiguous: is it the param value or the subcommand section?
[root.alpha] # "foo" is ambiguous: is it the --foo param or the [root.alpha.foo] subcommand? foo = ???
- tests.test_parameters.test_nested_subcommand_no_false_conflict_with_root_param(invoke)[source]ΒΆ
A nested subcommand can share a name with a root-level param without conflict.
The config paths are distinct (
root.verbosevsroot.alpha.verbose), so there is no ambiguity.
tests.test_pygments moduleΒΆ
- 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.Outputtokens, 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.
- tests.test_pygments.collect_classes(klass, prefix='Ansi')[source]ΒΆ
Returns all classes defined in
click_extra.pygmentsthat are a subclass ofklass, and whose name starts with the providedprefix.
tests.test_pytest moduleΒΆ
Test the Pytest helpers.
tests.test_sphinx moduleΒΆ
Fixtures and utilities for Sphinx testing.
tests.test_sphinx_alerts moduleΒΆ
Tests for GitHub alert syntax conversion in Sphinx with MyST parser.
- tests.test_sphinx_alerts.test_all_alert_types(alert_type)[source]ΒΆ
Test all supported alert types are converted correctly.
- tests.test_sphinx_alerts.test_alert_conversion(text, expected)[source]ΒΆ
Test GitHub alerts are converted to MyST admonitions.
When expected is None, no conversion should occur.
- tests.test_sphinx_alerts.test_sphinx_integration(sphinx_app, test_case)[source]ΒΆ
Integration-critical tests that verify Sphinx rendering behavior.
tests.test_sphinx_click moduleΒΆ
Tests for Sphinx directives click:source and click:run in rST and MyST formats.
- tests.test_sphinx_click.test_directive_functionality(sphinx_app, test_case)[source]ΒΆ
Test standard directive functionalities in both rST and MyST.
- tests.test_sphinx_click.test_directive_option_format(sphinx_app_rst)[source]ΒΆ
rST will fail to render if an
:option:is not followed by an empty line.
- tests.test_sphinx_click.test_directive_option_language_override(sphinx_app)[source]ΒΆ
Test that language override works for click:run directive.
- tests.test_sphinx_click.test_sphinx_directive_state_persistence(sphinx_app)[source]ΒΆ
Test that state persists between declare and run directives in real Sphinx.
tests.test_table moduleΒΆ
- tests.test_table.test_table_formats_definition()[source]ΒΆ
Check all table formats are accounted for and properly named.
- tests.test_table.test_all_table_formats_have_test_rendering()[source]ΒΆ
Check all table formats have a rendering test fixture defined.
- tests.test_table.test_all_table_rendering(invoke, cmd_decorator, option_decorator, format_name, expected)[source]ΒΆ
tests.test_telemetry moduleΒΆ
tests.test_testing moduleΒΆ
Test the testing utilities and the simulation of CLI execution.
- 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.
- tests.test_testing.test_temporary_fs(extra_runner)[source]ΒΆ
Check the CLI runner fixture properly encapsulated the filesystem in temporary directory.
- tests.test_testing.test_invoke_color_forced(invoke)[source]ΒΆ
Test colors are preserved while invoking, and forced to be rendered on Windows.
- tests.test_testing.test_extra_command_default_color()[source]ΒΆ
With @command, ExtraContext defaults root color=True and ColorOption defaults True. Verify ctx.color=True and ANSI codes present in output.
- tests.test_testing.test_extra_command_no_color_flag()[source]ΒΆ
Invoke with βno-color. Verify ctx.color=False and ANSI stripped from echo output.
- tests.test_testing.test_force_color_attribute()[source]ΒΆ
ExtraCliRunner.force_color=True overrides color parameter.
- tests.test_testing.test_no_color_envvar()[source]ΒΆ
NO_COLOR=1 env var causes ctx.color=False via ColorOption.
- tests.test_testing.test_force_color_envvar()[source]ΒΆ
FORCE_COLOR=1 env var keeps ctx.color=True via ColorOption.
- tests.test_testing.test_extra_context_root_defaults_color_true()[source]ΒΆ
Root ExtraContext without color= arg defaults to color=True.
- tests.test_testing.test_extra_context_inherits_from_parent()[source]ΒΆ
Child ExtraContext inherits color from parent when not set.
- tests.test_testing.test_extra_context_explicit_overrides_parent()[source]ΒΆ
Child ExtraContext with explicit color overrides parent.
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.
tests.test_types moduleΒΆ
- tests.test_types.test_click_choice_behavior()[source]ΒΆ
Lockdown the behavior of method inherited from Clickβs Choice type.
- Return type:
- tests.test_types.test_enum_string_choices(enum_definition, choice_source, result)[source]ΒΆ
- Return type:
- tests.test_types.test_enum_choice_show_aliases(enum_definition, choice_source, show_aliases, result)[source]ΒΆ
Test that EnumChoice correctly handles Enum with aliases.
- Return type:
- class tests.test_types.MyEnum(*values)[source]ΒΆ
Bases:
EnumProduce different strings for keys/names, values and str().
- FIRST_VALUE = 'first-value'ΒΆ
- SECOND_VALUE = 'second-value'ΒΆ
- tests.test_types.test_enum_choice_command(invoke, cmd_decorator, opt_decorator, case_sensitive, valid_args, invalid_args)[source]ΒΆ
Test EnumChoice used within an option.
- Return type:
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.
- tests.test_version.test_standalone_version_option(invoke, cmd_decorator, option_decorator)[source]ΒΆ
- tests.test_version.test_debug_output(invoke, cmd_decorator, option_decorator, assert_output_regex)[source]ΒΆ
- tests.test_version.test_custom_message(invoke, cmd_decorator, message, regex_stdout, assert_output_regex)[source]ΒΆ
- tests.test_version.test_context_meta_laziness(invoke, cmd_decorator)[source]ΒΆ
Accessing a single field from
ctx.metamust not evaluate unrelated fields.Ensures that the
_LazyVersionDictdefers property evaluation: readingclick_extra.versionshould not trigger expensive properties likeenv_infoor git fields.
- tests.test_version.test_module_version_parent_package_fallback(monkeypatch)[source]ΒΆ
module_versionfalls back to parent packageβs__version__.Simulates the Nuitka use-case: a CLI whose module is
myapp.__main__(no__version__), with the parent packagemyappproviding it.
- tests.test_version.test_cli_frame_fallback(monkeypatch)[source]ΒΆ
cli_frame()falls back to the outermost frame when all frames are from the Click ecosystem.
- tests.test_version.test_version_fields_forwarded_to_version_option(invoke)[source]ΒΆ
version_fieldson@commandforwards toExtraVersionOption.
- tests.test_version.test_version_fields_forwarded_on_group(invoke)[source]ΒΆ
version_fieldsworks on@grouptoo.
- tests.test_version.test_version_fields_multiple(invoke)[source]ΒΆ
Multiple fields can be overridden at once.
- tests.test_version.test_version_fields_rejects_unknown(invoke)[source]ΒΆ
Unknown field names raise
TypeError.
- 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/stable/click-concepts/#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
--versionoutput.
- tests.test_version.test_dev_version_appends_git_hash(invoke, cmd_decorator)[source]ΒΆ
A
.devversion gets a+hashsuffix appended (or not, if git is unavailable).
- tests.test_version.test_prebaked_dev_version_not_double_suffixed(invoke, cmd_decorator)[source]ΒΆ
A version with an existing
+is returned as-is β no second hash appended.
- tests.test_version.test_release_version_unchanged(invoke, cmd_decorator)[source]ΒΆ
A non-dev version is never modified.
- tests.test_version.init_file(tmp_path)[source]ΒΆ
Helper that creates a temporary __init__.py with the given content.
- tests.test_version.test_prebake_dev_version(init_file)[source]ΒΆ
A
.devversion gets+hashappended in the file.
- tests.test_version.test_prebake_single_quotes(init_file)[source]ΒΆ
Single-quoted
__version__is also handled.
- tests.test_version.test_prebake_already_baked_skipped(init_file)[source]ΒΆ
A version with existing
+is left untouched.
- tests.test_version.test_prebake_release_skipped(init_file)[source]ΒΆ
A release version (no
.dev) is not modified.
- tests.test_version.test_prebake_no_version_in_file(init_file)[source]ΒΆ
A file without
__version__returnsNone.
- tests.test_version.test_prebake_missing_local_version_raises(init_file)[source]ΒΆ
Calling without
local_versionraisesTypeError.