From cc1389d3a27d9e4a92a7a180fc6ba6ce9e059e35 Mon Sep 17 00:00:00 2001 From: kaliko Date: Wed, 11 Dec 2013 17:19:50 +0100 Subject: [PATCH] Add unit test for simastr module --- tests/__init__.py | 0 tests/test_simastr.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_simastr.py 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 + -- 2.39.2