tests.test_envvar module¶

tests.test_envvar.test_merge_envvar_ids(envvars, result)[source]¶
tests.test_envvar.test_parse_envvar_flag(value, expected)[source]¶
tests.test_envvar.test_machine_envvars_apply_to_the_built_in_default_only(invoke, args, envvar, default_map, expected)[source]¶

A machine-wide variable fills in only for a value nothing else set.

tests.test_envvar.test_clean_envvar_id(env_name, clean_name)[source]¶
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_envvar.envvars_test_cases()[source]¶
tests.test_envvar.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 command improves the situation by normalizing the envvar name.

tests.test_envvar.test_empty_envvar_falls_back_to_the_default(invoke, cmd_decorator, default)[source]¶

An empty variable is read as unset, so the flag keeps its own default.

Pins the rule the "" row of envvars_test_cases() relies on: Parameter.resolve_envvar_value guards its lookup with a bare if rv, so an empty value never reaches the flag’s type. The False that row expects is the option’s default showing through, which is why flipping the default flips the outcome with it.

tests.test_envvar.test_env_copy()[source]¶
tests.test_envvar.test_env_copy_removes_on_none(monkeypatch)[source]¶

A None value drops its variable, the way Click’s CliRunner reads it.

The only way to hide an inherited variable from a child: assigning the empty string leaves it set, which parse_envvar_flag() counts as activation.

tests.test_envvar.test_temporary_env_sets_unsets_and_restores(monkeypatch)[source]¶
tests.test_envvar.test_temporary_env_restores_after_a_rejected_value(monkeypatch)[source]¶

A change failing halfway through still restores the ones already made.

os.environ takes FRUIT, then rejects the integer: the same window an interrupt landing between two changes would hit.