def test_partialmatch(trie): base_key = "abc" expected = {f"{base_key}{i:d}": f"value{i:d}" for i in range(3)} trie.update(**expected) trie[base_key.upper()] = "anything_not_expected" result = trie.match(base_key) assert result.is_partial_match assert dict(result.partial) == expected
def test_iter(trie): def random_str(k: int = 3): return "".join(random.choices(string.ascii_lowercase, k=k)) starting_dict = {random_str(): random_str() for i in range(10)} trie.update(**starting_dict) for key, value in trie: assert starting_dict.pop(key) == value assert not starting_dict # All elements iterated over