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:

None

tests.test_types.test_enum_string_choices(enum_definition, choice_source, result)[source]ΒΆ
Return type:

None

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:

None

tests.test_types.kebab_case(choice)[source]ΒΆ

Reshape a Python identifier into a CLI-friendly choice string.

Return type:

str

class tests.test_types.AliasedStrategy(*values)[source]ΒΆ

Bases: Enum

Aliases declared in the class body, which every supported Python handles.

Unlike _add_alias_(), this needs no Python 3.13.

SELECT_OLDER = 1ΒΆ
SELECT_NEWEST = 2ΒΆ
DISCARD_NEWEST = 1ΒΆ
DISCARD_OLDER = 2ΒΆ
class tests.test_types.TransformedFormat(*values)[source]ΒΆ

Bases: Enum

PLAIN_TEXT = 'plain_text'ΒΆ
RICH_HTML = 'rich_html'ΒΆ
tests.test_types.test_enum_choice_transform(choice_source, transform, expected)[source]ΒΆ

transform reshapes the choice string produced by any source.

Return type:

None

tests.test_types.test_enum_choice_transform_with_aliases(choice_source)[source]ΒΆ

transform is what makes show_aliases usable with non-identifier choices.

Return type:

None

tests.test_types.test_enum_choice_transform_collision(show_aliases)[source]ΒΆ

A transform collapsing two spellings into one is rejected.

Return type:

None

tests.test_types.test_enum_choice_transform_non_string()[source]ΒΆ

A transform returning a non-string blames itself, not the choice source.

Return type:

None

tests.test_types.test_enum_choice_transform_raising()[source]ΒΆ

A transform blowing up is reported with the string it choked on.

Return type:

None

class tests.test_types.MyEnum(*values)[source]ΒΆ

Bases: Enum

Produce different strings for keys/names, values and str().

FIRST_VALUE = 'first-value'ΒΆ
SECOND_VALUE = 'second-value'ΒΆ
tests.test_types.test_enum_choice_internals(source, expected_choices)[source]ΒΆ
Return type:

None

tests.test_types.test_enum_choice_case_sensitivity(case_sensitive)[source]ΒΆ
Return type:

None

tests.test_types.test_enum_choice_shell_complete(source, expected)[source]ΒΆ

Completion offers normalized choice strings, never the Enum.member form.

Completion routes through Choice.normalize_choice(), so an EnumChoice suggests parseable strings (case-folded, as it is case-insensitive by default) instead of MyEnum.FIRST_VALUE.

Return type:

None

tests.test_types.test_enum_choice_rejects_non_enum_choices(choices)[source]ΒΆ

Anything but an Enum class is refused with a TypeError.

Return type:

None

tests.test_types.test_enum_choice_rejects_unknown_choice_source()[source]ΒΆ

A string naming no ChoiceSource member is refused with a ValueError.

Return type:

None

tests.test_types.test_enum_choice_duplicate_string()[source]ΒΆ
Return type:

None

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:

None

tests.test_types.test_enum_choice_default_value(invoke, cmd_decorator, opt_decorator, opt_type, default_value)[source]ΒΆ

Test EnumChoice used within an option with a default value.

Return type:

None

tests.test_types.test_enum_choice_multiple_default_value(invoke, cmd_decorator, opt_decorator, default_value, expected)[source]ΒΆ

A multiple=True EnumChoice resolves each member of its tuple default.

Regression test for the get_default() override stringifying the whole default tuple (str((MyEnum.FOO,))) instead of mapping each member, which made the default trip Click’s Value must be an iterable check.

Return type:

None

tests.test_types.test_enum_choice_none_default(invoke, cmd_decorator, opt_decorator)[source]ΒΆ

A single-value EnumChoice option defaulting to None stays unset.

Regression test for the get_default() override turning a None default into the choice string "None", which then failed its own validation.

Return type:

None

tests.test_types.test_enum_choice_variadic_default_value(invoke, cmd_decorator, opt_decorator, default_value, expected)[source]ΒΆ

A variadic (nargs=-1) EnumChoice argument resolves each member of its default.

Companion to test_enum_choice_multiple_default_value covering the other branch of the get_default() override: the nargs == -1 path taken by arguments rather than the multiple path taken by options. Both map get_choice_string() over the members of a tuple default instead of stringifying the whole tuple.

Return type:

None

tests.test_types.test_enum_choice_callback(invoke, cmd_decorator, opt_decorator, choice_source, cli_value)[source]ΒΆ

Test that option callbacks receive properly converted Enum members.

Return type:

None

tests.test_types.test_multi_choice_parses_input(raw, expected)[source]ΒΆ

convert() splits on the separator, strips whitespace, drops empties.

Return type:

None

tests.test_types.test_multi_choice_validates_against_choices()[source]ΒΆ

Unknown tokens raise BadParameter via self.fail().

Return type:

None

tests.test_types.test_multi_choice_validates_an_already_parsed_sequence()[source]ΒΆ

A list is checked like a raw token, not waved through as pre-parsed.

A configuration file hands the option a list where the command line hands it one string, so skipping the check on a sequence lets an unknown value travel to whatever consumes the selection.

Return type:

None

tests.test_types.test_multi_choice_case_insensitive_normalizes()[source]ΒΆ

The default matches case-insensitively and returns the canonical case.

Return type:

None

tests.test_types.test_multi_choice_case_sensitive_matches_exactly()[source]ΒΆ

case_sensitive=True rejects a token differing only in case.

Return type:

None

tests.test_types.test_choice_types_default_to_case_insensitive(choice_type)[source]ΒΆ

Every choice type click-extra defines matches regardless of case by default.

Return type:

None

tests.test_types.test_multi_choice_metavar(choices, separator, expected)[source]ΒΆ
Return type:

None

tests.test_types.test_multi_choice_in_click_option()[source]ΒΆ

End-to-end: MultiChoice plugs into a Click option like Choice does.

Return type:

None

tests.test_types.test_duration_parsing(value, expected)[source]ΒΆ
Return type:

None

tests.test_types.test_duration_passthrough_timedelta()[source]ΒΆ

An already-parsed timedelta is returned unchanged (idempotent conversion).

Return type:

None

tests.test_types.test_duration_invalid(value)[source]ΒΆ
Return type:

None

tests.test_types.test_duration_rejects_calendar_units(value)[source]ΒΆ

Months and years are explicitly rejected because their length is ambiguous.

Return type:

None

tests.test_types.test_duration_absolute_timestamp(value)[source]ΒΆ

An RFC 3339 timestamp is converted to now - timestamp at parse time.

Return type:

None

tests.test_types.test_duration_future_timestamp_parses_to_none()[source]ΒΆ

A timestamp in the future parses to None, read as β€œno cutoff”.

Return type:

None

tests.test_types.test_duration_in_click_option()[source]ΒΆ

End-to-end: Duration plugs into a Click option.

Return type:

None

tests.test_types.test_parse_duration(value, expected)[source]ΒΆ
Return type:

None

tests.test_types.test_parse_duration_passthrough_timedelta()[source]ΒΆ

An existing timedelta is returned unchanged, like Duration.convert.

Return type:

None

tests.test_types.test_parse_duration_never_raises(value)[source]ΒΆ

The umbrella parser mirrors Duration but returns None instead of failing.

Return type:

None

tests.test_types.test_parse_friendly_duration(value, expected)[source]ΒΆ
Return type:

None

tests.test_types.test_parse_iso8601_duration(value, expected)[source]ΒΆ
Return type:

None