From: kaliko Date: Wed, 11 Dec 2013 16:19:50 +0000 (+0100) Subject: Add unit test for simastr module X-Git-Tag: mpd-sima/0.12.0pr3~21 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=cc1389d3a27d9e4a92a7a180fc6ba6ce9e059e35;p=mpd-sima.git Add unit test for simastr module --- diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_simastr.py b/tests/test_simastr.py new file mode 100644 index 0000000..c62af39 --- /dev/null +++ b/tests/test_simastr.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +import unittest + +import sima.lib.simastr + + +def fuzzystr(sta, stb): + afz = sima.lib.simastr.SimaStr(sta) + bfz = sima.lib.simastr.SimaStr(stb) + return afz == bfz + + + +class TestSequenceFunctions(unittest.TestCase): + + def test_fuzzystr(self): + sima.lib.simastr.SimaStr.diafilter = False + self.assertFalse(fuzzystr('eeee', 'éééé')) + tests = [ + ('eeee', 'éééé', self.assertTrue), + ('The Doors', 'Doors', self.assertTrue), + ('Tigres Del Norte', 'Los Tigres Del Norte', self.assertTrue), + ( 'The Desert Sessions & PJ Harvey', + 'Desert Sessions And PJ Harvey', + self.assertTrue + ), + ] + sima.lib.simastr.SimaStr.diafilter = True + for sta, stb, assertfunc in tests: + assertfunc(fuzzystr(sta, stb), '"{0}" == "{1}"'.format(sta, stb)) + +# vim: ai ts=4 sw=4 sts=4 expandtab +