def test_prefix_exists(self): trie = Trie() trie.add('foob', 1) trie.add('fooba', 2) trie.add('foobb', 3) trie.add('foobar', 4) trie.add('foobaz', 5) values = list(trie.values_for_prefix('foo')) assert len(values) == 5 for i in range(1, 6): assert i in values
def test_prefix_does_not_exist(self): trie = Trie() with pytest.raises(KeyNotFound): trie.values_for_prefix('foobar')