Merge pull request #144 from maxbachmann/tests

Fix unit tests on Python2.7
This commit is contained in:
Max Bachmann 2021-10-08 00:11:05 +02:00 committed by GitHub
commit b239d5bc6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -21,6 +21,9 @@ scorers = [
fuzz.QRatio
]
if sys.version_info < (3,0,0):
chr = unichr
class RatioTest(unittest.TestCase):
s1 = "new york mets"
s1a = "new york mets"
@ -87,8 +90,8 @@ class RatioTest(unittest.TestCase):
self.assertAlmostEqual(fuzz.partial_ratio("ax b", "a b a c b"), 85.71428, places=4)
def testIssue138(self):
str1 = 'a'*65
str2 = 'a' + chr(256) + 'a'*63
str1 = u'a'*65
str2 = u'a' + chr(256) + u'a'*63
self.assertAlmostEqual(fuzz.partial_ratio(str1, str2), 98.46153, places=4)
def test_empty_string():
@ -189,4 +192,4 @@ def test_help(scorer):
help(scorer)
if __name__ == '__main__':
unittest.main()
unittest.main()