tests.test_utils moduleΒΆ

Test the generic helpers of the private utility module.

tests.test_utils.test_exception_chain_ends_on_a_loop()[source]ΒΆ

Two exceptions naming each other are each yielded once.

tests.test_utils.test_exception_chain_follows_the_context_without_a_cause()[source]ΒΆ
tests.test_utils.test_exception_chain_of_nothing_is_empty()[source]ΒΆ
tests.test_utils.test_exception_chain_prefers_the_cause()[source]ΒΆ

The cause an exception was raised from wins over the one it replaced.

tests.test_utils.test_generator_tag()[source]ΒΆ
tests.test_utils.test_missing_extra_message()[source]ΒΆ
tests.test_utils.test_patch_attr_restores_on_exit()[source]ΒΆ
tests.test_utils.test_patch_attr_restores_on_error()[source]ΒΆ
tests.test_utils.test_patch_attr_requires_existing_attribute()[source]ΒΆ
tests.test_utils.test_flatten_collapses_nested_iterables()[source]ΒΆ

Every nesting level is walked, strings and bytes staying whole.

tests.test_utils.test_flatten_of_nothing_is_empty()[source]ΒΆ
tests.test_utils.test_shrinkuser_spells_the_home_directory_as_a_tilde()[source]ΒΆ
tests.test_utils.test_shrinkuser_takes_another_home_spelling()[source]ΒΆ
tests.test_utils.test_deep_merge_merges_dicts_and_takes_every_other_value_from_the_overlay()[source]ΒΆ
tests.test_utils.test_deep_merge_leaves_both_arguments_alone()[source]ΒΆ
tests.test_utils.SET_NESTED_PATHS: tuple[tuple[tuple[str, ...], object], ...] = ((('orchard', 'apple', 'count'), 3), (('orchard', 'apple', 'color'), 'red'), (('orchard', 'pear'), {'count': 1}), (('orchard', 'pear'), {'color': 'green'}), (('orchard', 'pear', 'count'), 2), (('garden',), 'tomato'), (('garden', 'basil'), True), (('orchard', 'apple'), ['fuji', 'gala']), (('orchard', 'apple', 'count'), 4), (('barn',), {'hay': {'bales': 10}}), (('barn', 'hay'), {'straw': 2}))ΒΆ

Paths and values covering every case of a merge: a fresh path, a shared prefix, two dictionaries merging, a dictionary replacing a value, and the reverse.

tests.test_utils.test_set_nested_matches_merging_one_path_trees()[source]ΒΆ

Setting each path in place builds the tree the one-path merges built.

tests.test_utils.test_set_nested_rejects_an_empty_path()[source]ΒΆ
tests.test_utils.test_walk_up_starts_at_the_start_and_ends_at_the_root(tmp_path)[source]ΒΆ
tests.test_utils.test_parse_bool(text, expected)[source]ΒΆ

The spellings read the same whatever their case and surrounding blanks.

tests.test_utils.test_boolean_states_match_configparser()[source]ΒΆ

The copy holds the spellings the standard library reads, no more.

tests.test_utils.BLANK_TREE: dict[str, object] = {'city': 'Lyon', 'forecast': {'rain': None, 'sky': '', 'wind': {}}, 'harbor': {'boats': 0, 'docks': [], 'flags': False}, 'lake': None, 'orchard': {}, 'river': ''}ΒΆ

A tree holding a blank value of each kind, at the top and one level down.

tests.test_utils.test_remove_blanks(kwargs, expected)[source]ΒΆ

Each kind of blank value goes, unless its remove_* argument keeps it.

A falsy value that is not blank, like 0, False or an empty list, stays.

tests.test_utils.test_remove_blanks_drops_a_dict_emptied_by_the_cleaning()[source]ΒΆ
tests.test_utils.test_remove_blanks_leaves_the_tree_alone()[source]ΒΆ