Ticket #17555: 17555.diff
File 17555.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..c3666ed
- + 1 from django.test import TestCase 2 from django.test.utils import override_settings 3 from django.utils import translation 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 @override_settings(USE_I18N = True) 14 class TranslationI18nEnabledTests(TranslationTestCase): 15 def test_get_language_from_path(self): 16 self.assertEqual(translation.get_language_from_path(self.path_slash), self.language) 17 self.assertEqual(translation.get_language_from_path(self.path_no_slash), self.language) 18 self.assertEqual(translation.get_language_from_path(self.path_unknown), None) 19 20 21 @override_settings(USE_I18N = False) 22 class TranslationI18nDisabledTests(TranslationTestCase): 23 def test_get_language_from_path(self): 24 self.assertEqual(translation.get_language_from_path(self.path_slash), None) 25 self.assertEqual(translation.get_language_from_path(self.path_no_slash), None) 26 self.assertEqual(translation.get_language_from_path(self.path_unknown), None) 27 28 No newline at end of file