def testQRatioForceAscii(self): s1 = "ABCD\u00C1" s2 = "ABCD" score = fuzz.WRatio(s1, s2, force_ascii=True) self.assertEqual(score, 100) score = fuzz.WRatio(s1, s2, force_ascii=False) self.assertLess(score, 100)
def testWRatioUnicodeString(self): s1 = "\u00C1" s2 = "ABCD" score = fuzz.WRatio(s1, s2) self.assertEqual(0, score) # Cyrillic. s1 = "\u043f\u0441\u0438\u0445\u043e\u043b\u043e\u0433" s2 = "\u043f\u0441\u0438\u0445\u043e\u0442\u0435\u0440\u0430\u043f\u0435\u0432\u0442" score = fuzz.WRatio(s1, s2, force_ascii=False) self.assertNotEqual(0, score) # Chinese. s1 = "\u6211\u4e86\u89e3\u6570\u5b66" s2 = "\u6211\u5b66\u6570\u5b66" score = fuzz.WRatio(s1, s2, force_ascii=False) self.assertNotEqual(0, score)
def testQRatioUnicode(self): self.assertEqual(fuzz.WRatio(unicode(self.s1), unicode(self.s1a)), 100)
def testWRatioMisorderedMatch(self): # misordered full matches are scaled by .95 self.assertEqual(fuzz.WRatio(self.s4, self.s5), 95)
def testWRatioPartialMatch(self): # a partial match is scaled by .9 self.assertEqual(fuzz.WRatio(self.s1, self.s3), 90)
def testWRatioCaseInsensitive(self): self.assertEqual(fuzz.WRatio(self.s1, self.s2), 100)
def testWRatioEqual(self): self.assertEqual(fuzz.WRatio(self.s1, self.s1a), 100)