def test_to_list_includes_all_words(self): words = ["bat", "cat"] token_set = TokenSet.from_list(words) assert set(words) == set(token_set.to_list())
def test_from_list_is_minimal(self): token_set = TokenSet.from_list(["ac", "dc"]) ac_node = token_set.edges["a"].edges["c"] dc_node = token_set.edges["d"].edges["c"] assert ac_node == dc_node
def test_from_list_with_unsorted_list(self): with pytest.raises(BaseLunrException): TokenSet.from_list(["z", "a"])
def test_from_list_with_sorted_list(self): token_set = TokenSet.from_list(["a", "z"]) assert ["a", "z"] == sorted(token_set.to_list())
def _create_token_set(self): """Creates a token set of all tokens in the index using `lunr.TokenSet` """ self.token_set = TokenSet.from_list( sorted(list(self.inverted_index.keys())))