Ticket #17555: 17555.v2.diff
File 17555.v2.diff, 2.4 KB (added by , 13 years ago) |
---|
-
django/utils/translation/trans_real.py
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 28d2012..419b380 100644
a b accept_language_re = re.compile(r''' 38 38 (?:\s*,\s*|$) # Multiple accepts per header. 39 39 ''', re.VERBOSE) 40 40 41 language_code_prefix_re = re.compile(r'^/([\w-]+) /')41 language_code_prefix_re = re.compile(r'^/([\w-]+)(/|$)') 42 42 43 43 def to_locale(language, to_lower=False): 44 44 """ -
tests/regressiontests/utils/tests.py
diff --git a/tests/regressiontests/utils/tests.py b/tests/regressiontests/utils/tests.py index f5ca06e..0e34651 100644
a b from .timezone import TimezoneTests 26 26 from .crypto import TestUtilsCryptoPBKDF2 27 27 from .archive import TestZip, TestTar, TestGzipTar, TestBzip2Tar 28 28 from .regex_helper import NormalizeTests 29 from .translation import TranslationI18nEnabledTests, TranslationI18nDisabledTests -
new file tests/regressiontests/utils/translation.py
diff --git a/tests/regressiontests/utils/translation.py b/tests/regressiontests/utils/translation.py new file mode 100644 index 0000000..d86ed1f
- + 1 from django.test import TestCase 2 from django.utils.translation.trans_real import get_language_from_path as get_language_from_path_real 3 from django.utils.translation.trans_null import get_language_from_path as get_language_from_path_null 4 5 class TranslationTestCase(TestCase): 6 def setUp(self): 7 self.language = 'pl' 8 self.path_slash = '/%s/' % self.language 9 self.path_no_slash = '/%s' % self.language 10 self.path_unknown = '/xyz/' 11 12 13 class TranslationI18nEnabledTests(TranslationTestCase): 14 def test_get_language_from_path(self): 15 self.assertEqual(get_language_from_path_real(self.path_slash), self.language) 16 self.assertEqual(get_language_from_path_real(self.path_no_slash), self.language) 17 self.assertEqual(get_language_from_path_real(self.path_unknown), None) 18 19 20 class TranslationI18nDisabledTests(TranslationTestCase): 21 def test_get_language_from_path(self): 22 self.assertEqual(get_language_from_path_null(self.path_slash), None) 23 self.assertEqual(get_language_from_path_null(self.path_no_slash), None) 24 self.assertEqual(get_language_from_path_null(self.path_unknown), None) 25