From b3d115758e2ea88c9a2cab2b15149774071a6b5a Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Fri, 8 Oct 2021 00:07:20 +0200 Subject: [PATCH] Fix unit tests on Python2.7 --- tests/test_fuzz.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_fuzz.py b/tests/test_fuzz.py index 3097541..54e74be 100644 --- a/tests/test_fuzz.py +++ b/tests/test_fuzz.py @@ -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() \ No newline at end of file + unittest.main()