tests.test_multicall module

Tests multicall / argv[0] dispatch and the invocation-name hook.

tests.test_multicall.make_kitchen(personalities=None, **group_kwargs)[source]

A fresh multicall CLI per test, to keep process-global state from leaking.

The domain is deliberately a kitchen: the test suite asserts dispatch mechanics, not any real tool’s behavior.

tests.test_multicall.test_argv0_dispatch(runner, monkeypatch)[source]

With no explicit prog_name, the basename of argv[0] dispatches.

tests.test_multicall.test_env_prefix_follows_personality(runner)[source]

A personality reads its own <NAME>_* envvars, like a standalone binary.

tests.test_multicall.test_explicit_mapping_replaces_identity(runner)[source]

An explicit personalities mapping is exhaustive, not additive.

tests.test_multicall.test_explicit_prog_name_wins(runner, monkeypatch)[source]

An explicit prog_name takes precedence over argv[0].

tests.test_multicall.test_extra_tokens_prepended(runner)[source]

Personality tokens are prepended to the user’s arguments.

tests.test_multicall.test_flat_parse_any_order(runner)[source]

Group and subcommand options mix freely in a personality.

tests.test_multicall.test_group_callback_skipped_in_personality_mode(runner)[source]

A personality is standalone: the group’s callback does not run.

tests.test_multicall.test_group_mode_unchanged(runner)[source]

A non-matching invocation name leaves the regular group behavior intact.

tests.test_multicall.test_help_conformance(runner)[source]

A personality’s help lists every option the group’s help lists.

This is what catches the Cloup layout trap: patching params on a copy updates the parser but not the help formatter, which is computed from params at __init__ time.

tests.test_multicall.test_hidden_subcommand_is_not_a_default_personality(runner)[source]

The default identity mapping skips hidden and synthetic subcommands.

tests.test_multicall.test_invocation_name_meta_key(runner)[source]

ctx.meta exposes the invocation name on the root context.

tests.test_multicall.test_no_envvar_leak_into_group_mode(runner)[source]

Building a personality must not rewrite the original params’ envvars.

tests.test_multicall.test_resolve_invocation_name(runner, monkeypatch, argv0, expected)[source]

The detector uses the unresolved basename and strips .exe.

tests.test_multicall.test_unknown_subcommand_in_mapping(runner)[source]

A personality mapping an absent subcommand fails loudly at dispatch.

tests.test_multicall.test_version_names_each_personality(runner)[source]

Each personality’s --version names itself, in sequence.

Regression test: VersionOption used to cache prog_name on the instance, pinning the first name seen in a process forever. The warm-up invocation with debug logging matters: it resolves every version field without anyone calling --version at all.

tests.test_multicall.test_version_prog_name_varies_without_multicall(runner)[source]

--version follows an explicit prog_name even in plain group mode.

tests.test_multicall.test_personalities_subcommand(runner)[source]

The auto-injected personalities subcommand lists the names.

tests.test_multicall.test_personalities_command_can_be_disabled(runner)[source]

personalities_command=False suppresses the listing subcommand.

tests.test_multicall.test_personalities_command_can_be_overridden(runner)[source]

A personalities subcommand of the author’s replaces the injected one.

tests.test_multicall.test_injected_subcommands_listed_last_in_declaration_order()[source]

help and personalities trail the author’s own subcommands.

tests.test_multicall.test_plain_click_subcommand_is_a_personality(runner)[source]

A subcommand built by Click alone dispatches like any other.

tests.test_multicall.test_normalize_personality()[source]

Personality values normalize to non-empty token tuples.

tests.test_multicall.test_deepcopy_keeps_every_sentinel_identical()[source]

A copied parameter carries its enum members over, it does not rebuild them.

An enum member is a singleton, so a copy handing back an equal-but-distinct one is already wrong, and the object() behind a PEP 661 sentinel never survives a rebuild. Walking the whole default option set catches the next parameter to grow one.

tests.test_multicall.test_version_option_deepcopy_drops_cache()[source]

Deepcopying a warmed-up VersionOption yields fresh field resolution.

tests.test_multicall.test_lazy_subcommand_is_a_personality(runner, tmp_path, monkeypatch)[source]

A lazy multicall group answers to a subcommand it has not imported yet.

Personality dispatch runs before any context exists, so the name is resolved through the lazy registry rather than the subcommands already loaded. Invoked as bake, the group imports the subcommand and runs it, instead of falling through to its own usage screen.