Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_empty(self):
self.assertEqual(pylev.levenshtein('', ''), 0)
def test_same(self):
self.assertEqual(pylev.levenshtein('kitten', 'kitten'), 0)
def test_painful(self):
# This is much faster than the above.
self.assertEqual(pylev.levenshtein('CUNsperrICY', 'conspiracy'), 8)
def test_classic(self):
self.assertEqual(pylev.levenshtein('kitten', 'sitting'), 3)
def test_long(self):
self.assertEqual(pylev.classic_levenshtein('confide', 'deceit'), 6)
def test_painful(self):
# This is pretty slow but should work.
self.assertEqual(pylev.classic_levenshtein('CUNsperrICY', 'conspiracy'), 8)
def test_classic(self):
self.assertEqual(pylev.classic_levenshtein('kitten', 'sitting'), 3)
def test_empty(self):
self.assertEqual(pylev.classic_levenshtein('', ''), 0)
def test_same(self):
self.assertEqual(pylev.classic_levenshtein('kitten', 'kitten'), 0)
def levenshtein_ratio(s1, s2):
assert len(s1) > 0 and len(s2) > 0
return pylev.levenshtein(s1, s2) / float(max(len(s1),len(s2)))