示例#1
0
    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())
示例#2
0
    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
示例#3
0
 def test_from_list_with_unsorted_list(self):
     with pytest.raises(BaseLunrException):
         TokenSet.from_list(["z", "a"])
示例#4
0
 def test_from_list_with_sorted_list(self):
     token_set = TokenSet.from_list(["a", "z"])
     assert ["a", "z"] == sorted(token_set.to_list())
示例#5
0
 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())))