diff --git a/src/run_tests.py b/src/run_tests.py index 75a8087..66bb6ce 100644 --- a/src/run_tests.py +++ b/src/run_tests.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import unittest -testmodules = ['test.test_storage', 'test.test_extractors', 'test.test_fixes'] +testmodules = ['test.test_storage', 'test.test_extractors', 'test.test_fixes', 'test.test_i18n'] suite = unittest.TestSuite() diff --git a/src/test/test_fixes.py b/src/test/test_fixes.py index bd8d73e..194ba38 100644 --- a/src/test/test_fixes.py +++ b/src/test/test_fixes.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Unittests for fixers applied in some cases. """ from __future__ import unicode_literals import os diff --git a/src/test/test_i18n.py b/src/test/test_i18n.py new file mode 100644 index 0000000..02b65fa --- /dev/null +++ b/src/test/test_i18n.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +""" Unittests for internationalization features. This test is here for avoiding breaking things between gettext for python 2 and 3. """ +from __future__ import unicode_literals +import os +import unittest +import sys +import i18n + +# Python 2/3 compat. +if sys.version[0] == "2": + strtype = unicode +else: + strtype = str + +class i18nTestCase(unittest.TestCase): + + def test_i18n_unicode(self): + """ Testing gettext function so it will generate only unicode strings both in python 2 and 3. """ + i18n.setup() + # If something happened to i18n, it should raise a traceback in the next call + translated_str = _("This is a string with no special characters.") + self.assertIsInstance(translated_str, strtype) + # Test something with a special character here. + localized_fake_str = _("Привет всем") + self.assertIsInstance(localized_fake_str, strtype) + +if __name__ == "__main__": + unittest.main() \ No newline at end of file