def matches_entry(self, model, itr, user_data=None): entry_text = self._entry.get_text() if not entry_text: # everything matches empty string return True value = model[itr][0] eng_value = self._xkl_wrapper.get_layout_variant_description(value, xlated=False) xlated_value = self._xkl_wrapper.get_layout_variant_description(value) translit_value = strip_accents(xlated_value).lower() entry_text = entry_text.lower() return have_word_match(entry_text, eng_value) or have_word_match(entry_text, xlated_value) \ or have_word_match(entry_text, translit_value)
def test_have_word_match(self): """Test have_word_match.""" assert util.have_word_match("word1 word2", "word1 word2 word3") assert util.have_word_match("word1 word2", "word2 word1 word3") assert util.have_word_match("word2 word1", "word3 word1 word2") assert util.have_word_match("word1", "word1 word2") assert util.have_word_match("word1 word2", "word2word1 word3") assert util.have_word_match("word2 word1", "word3 word1word2") assert util.have_word_match("word1", "word1word2") assert util.have_word_match("", "word1") assert not util.have_word_match("word3 word1", "word1") assert not util.have_word_match("word1 word3", "word1 word2") assert not util.have_word_match("word3 word2", "word1 word2") assert not util.have_word_match("word1word2", "word1 word2 word3") assert not util.have_word_match("word1", "") assert not util.have_word_match("word1", None) assert not util.have_word_match(None, "word1") assert not util.have_word_match("", None) assert not util.have_word_match(None, "") assert not util.have_word_match(None, None) # Compare designated unicode and "standard" unicode string and make sure nothing crashes assert util.have_word_match("fête", "fête champêtre") assert util.have_word_match("fête", "fête champêtre")
def have_word_match_test(self): """Test have_word_match.""" self.assertTrue( util.have_word_match("word1 word2", "word1 word2 word3")) self.assertTrue( util.have_word_match("word1 word2", "word2 word1 word3")) self.assertTrue( util.have_word_match("word2 word1", "word3 word1 word2")) self.assertTrue(util.have_word_match("word1", "word1 word2")) self.assertTrue(util.have_word_match("word1 word2", "word2word1 word3")) self.assertTrue(util.have_word_match("word2 word1", "word3 word1word2")) self.assertTrue(util.have_word_match("word1", "word1word2")) self.assertTrue(util.have_word_match("", "word1")) self.assertFalse(util.have_word_match("word3 word1", "word1")) self.assertFalse(util.have_word_match("word1 word3", "word1 word2")) self.assertFalse(util.have_word_match("word3 word2", "word1 word2")) self.assertFalse( util.have_word_match("word1word2", "word1 word2 word3")) self.assertFalse(util.have_word_match("word1", "")) self.assertFalse(util.have_word_match("word1", None)) self.assertFalse(util.have_word_match(None, "word1")) self.assertFalse(util.have_word_match("", None)) self.assertFalse(util.have_word_match(None, "")) self.assertFalse(util.have_word_match(None, None)) # Compare designated unicode and "standard" unicode string and make sure nothing crashes self.assertTrue(util.have_word_match("fête", u"fête champêtre")) self.assertTrue(util.have_word_match(u"fête", "fête champêtre"))
def have_word_match_test(self): """Test have_word_match.""" self.assertTrue(util.have_word_match("word1 word2", "word1 word2 word3")) self.assertTrue(util.have_word_match("word1 word2", "word2 word1 word3")) self.assertTrue(util.have_word_match("word2 word1", "word3 word1 word2")) self.assertTrue(util.have_word_match("word1", "word1 word2")) self.assertTrue(util.have_word_match("word1 word2", "word2word1 word3")) self.assertTrue(util.have_word_match("word2 word1", "word3 word1word2")) self.assertTrue(util.have_word_match("word1", "word1word2")) self.assertTrue(util.have_word_match("", "word1")) self.assertFalse(util.have_word_match("word3 word1", "word1")) self.assertFalse(util.have_word_match("word1 word3", "word1 word2")) self.assertFalse(util.have_word_match("word3 word2", "word1 word2")) self.assertFalse(util.have_word_match("word1word2", "word1 word2 word3")) self.assertFalse(util.have_word_match("word1", "")) self.assertFalse(util.have_word_match("word1", None)) self.assertFalse(util.have_word_match(None, "word1")) self.assertFalse(util.have_word_match("", None)) self.assertFalse(util.have_word_match(None, "")) self.assertFalse(util.have_word_match(None, None)) # Compare designated unicode and "standard" unicode string and make sure nothing crashes self.assertTrue(util.have_word_match("fête", u"fête champêtre")) self.assertTrue(util.have_word_match(u"fête", "fête champêtre"))