diff options
author | Tim Graham <timograham@gmail.com> | 2015-01-09 15:08:16 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2015-01-17 11:23:43 -0500 |
commit | f0a1df0b0139a7f5a576dff966210b5d52247650 (patch) | |
tree | db243673fa89ac0addb5f855961a7cfd5a8c3579 /tests | |
parent | b845951fd41cf6a380b3e09eeb30f7d105c37061 (diff) | |
download | django-f0a1df0b0139a7f5a576dff966210b5d52247650.tar.gz |
Removed deprecated Chinese language codes; refs #18149.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/deprecation/tests.py | 22 | ||||
-rw-r--r-- | tests/i18n/tests.py | 46 |
2 files changed, 12 insertions, 56 deletions
diff --git a/tests/deprecation/tests.py b/tests/deprecation/tests.py index 2d9a9beb69..ccc4f2351b 100644 --- a/tests/deprecation/tests.py +++ b/tests/deprecation/tests.py @@ -4,9 +4,9 @@ import os import unittest import warnings -from django.test import SimpleTestCase, override_settings +from django.test import SimpleTestCase from django.test.utils import reset_warning_registry -from django.utils import six, translation +from django.utils import six from django.utils.deprecation import RenameMethodsBase from django.utils.encoding import force_text @@ -175,24 +175,6 @@ class RenameMethodsTests(SimpleTestCase): ]) -@override_settings(USE_I18N=True) -class DeprecatedChineseLanguageCodes(SimpleTestCase): - def test_deprecation_warning(self): - with warnings.catch_warnings(record=True) as recorded: - warnings.simplefilter('always') - with translation.override('zh-cn'): - pass - with translation.override('zh-tw'): - pass - msgs = [str(warning.message) for warning in recorded] - self.assertEqual(msgs, [ - "The use of the language code 'zh-cn' is deprecated. " - "Please use the 'zh-hans' translation instead.", - "The use of the language code 'zh-tw' is deprecated. " - "Please use the 'zh-hant' translation instead.", - ]) - - class DeprecatingSimpleTestCaseUrls(unittest.TestCase): def test_deprecation(self): diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index a0df8daddf..f3ae0288c2 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -972,11 +972,11 @@ class MiscTests(TestCase): self.assertEqual(g(r), 'es') # This tests the following scenario: there isn't a main language (zh) - # translation of Django but there is a translation to variation (zh_CN) - # the user sets zh-cn as the preferred language, it should be selected + # translation of Django but there is a translation to variation (zh-hans) + # the user sets zh-hans as the preferred language, it should be selected # by Django without falling back nor ignoring it. - r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,de'} - self.assertEqual(g(r), 'zh-cn') + r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-hans,de'} + self.assertEqual(g(r), 'zh-hans') r.META = {'HTTP_ACCEPT_LANGUAGE': 'NL'} self.assertEqual('nl', g(r)) @@ -1022,32 +1022,6 @@ class MiscTests(TestCase): r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-tw,en'} self.assertEqual(g(r), 'zh-hant') - @override_settings( - LANGUAGES=( - ('en', 'English'), - ('zh-cn', 'Simplified Chinese'), - ('zh-hans', 'Simplified Chinese'), - ('zh-hant', 'Traditional Chinese'), - ('zh-tw', 'Traditional Chinese'), - ) - ) - def test_backwards_compatibility(self): - """ - While the old chinese language codes are being deprecated, they should - still work as before the new language codes were introduced. - - refs #18419 -- this is explicitly for backwards compatibility and - should be removed in Django 1.9 - """ - g = get_language_from_request - r = self.rf.get('/') - r.COOKIES = {} - r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,en'} - self.assertEqual(g(r), 'zh-cn') - - r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-tw,en'} - self.assertEqual(g(r), 'zh-tw') - def test_special_fallback_language(self): """ Some languages may have special fallbacks that don't follow the simple @@ -1085,12 +1059,12 @@ class MiscTests(TestCase): self.assertEqual(g(r), 'es') # This tests the following scenario: there isn't a main language (zh) - # translation of Django but there is a translation to variation (zh_CN) - # the user sets zh-cn as the preferred language, it should be selected + # translation of Django but there is a translation to variation (zh-hans) + # the user sets zh-hans as the preferred language, it should be selected # by Django without falling back nor ignoring it. - r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'zh-cn'} + r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'zh-hans'} r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'} - self.assertEqual(g(r), 'zh-cn') + self.assertEqual(g(r), 'zh-hans') def test_get_language_from_path_real(self): g = trans_real.get_language_from_path @@ -1238,8 +1212,8 @@ class TestLanguageInfo(TestCase): """ li = get_language_info('zh-my') self.assertEqual(li['code'], 'zh-hans') - li = get_language_info('zh-cn') - self.assertEqual(li['code'], 'zh-cn') + li = get_language_info('zh-hans') + self.assertEqual(li['code'], 'zh-hans') class MultipleLocaleActivationTests(TestCase): |