| Total Complexity | 4 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | import sys |
||
| 8 | class TestLevenShtein(TestCase): |
||
| 9 | """ |
||
| 10 | Test for the levenshtein module |
||
| 11 | """ |
||
| 12 | |||
| 13 | def test_same_word_should_zero(self): |
||
| 14 | """ |
||
| 15 | if we use the same word there should be no difference required |
||
| 16 | """ |
||
| 17 | diff = levenshtein.levenshtein("hello", "hello") |
||
| 18 | |||
| 19 | self.assertEqual(diff, 0) |
||
| 20 | |||
| 21 | def test_zero_words_should_zero(self): |
||
| 22 | """ |
||
| 23 | special case with same word but both are empty |
||
| 24 | """ |
||
| 25 | diff = levenshtein.levenshtein("", "") |
||
| 26 | |||
| 27 | self.assertEqual(diff, 0) |
||
| 28 | |||
| 29 | def test_first_longer_equal_one(self): |
||
| 30 | """ |
||
| 31 | try with same word base but missing characters |
||
| 32 | """ |
||
| 33 | diff = levenshtein.levenshtein("hello", "hell") |
||
| 34 | |||
| 35 | self.assertEqual(diff, 1) |
||
| 36 | |||
| 37 | def test_second_longer_equal_one(self): |
||
| 38 | """ |
||
| 39 | reversed case of the missing character. |
||
| 40 | method should work in both ways and not return a negative difference |
||
| 41 | """ |
||
| 42 | diff = levenshtein.levenshtein("hell", "hello") |
||
| 43 | |||
| 44 | self.assertEqual(diff, 1) |
||
| 45 |