From 8c8f94fe9dcdd4983ebeb59951e6f7399bc287a2 Mon Sep 17 00:00:00 2001 From: Ɓukasz Langa Date: Sun, 24 Feb 2013 14:43:45 +0100 Subject: Fixes #19763 - LocaleMiddleware should check for supported languages in settings.LANGUAGE_CODE --- tests/regressiontests/i18n/patterns/tests.py | 10 +++++++++- tests/regressiontests/i18n/tests.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/regressiontests/i18n/patterns/tests.py b/tests/regressiontests/i18n/patterns/tests.py index 0a785ab1d6..3f77136efb 100644 --- a/tests/regressiontests/i18n/patterns/tests.py +++ b/tests/regressiontests/i18n/patterns/tests.py @@ -19,7 +19,7 @@ from django.utils import translation TEMPLATE_DIRS=( os.path.join(os.path.dirname(upath(__file__)), 'templates'), ), - LANGUAGE_CODE='en', + LANGUAGE_CODE='en-us', LANGUAGES=( ('nl', 'Dutch'), ('en', 'English'), @@ -171,6 +171,14 @@ class URLRedirectTests(URLTestCaseBase): response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) + def test_pl_pl_redirect(self): + # language from outside of the supported LANGUAGES list + response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='pl-pl') + self.assertRedirects(response, '/en/account/register/') + + response = self.client.get(response['location']) + self.assertEqual(response.status_code, 200) + class URLVaryAcceptLanguageTests(URLTestCaseBase): """ diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index aaa9b12c3b..520469ca79 100644 --- a/tests/regressiontests/i18n/tests.py +++ b/tests/regressiontests/i18n/tests.py @@ -958,7 +958,7 @@ class TestLanguageInfo(TestCase): self.assertEqual(li['bidi'], False) def test_unknown_language_code(self): - six.assertRaisesRegex(self, KeyError, "Unknown language code '?xx'?.", get_language_info, 'xx-xx') + six.assertRaisesRegex(self, KeyError, r"Unknown language code xx\.", get_language_info, 'xx') def test_unknown_only_country_code(self): li = get_language_info('de-xx') @@ -968,7 +968,7 @@ class TestLanguageInfo(TestCase): self.assertEqual(li['bidi'], False) def test_unknown_language_code_and_country_code(self): - six.assertRaisesRegex(self, KeyError, "Unknown language code '?xx-xx'? and '?xx'?.", get_language_info, 'xx-xx') + six.assertRaisesRegex(self, KeyError, r"Unknown language code xx-xx and xx\.", get_language_info, 'xx-xx') class MultipleLocaleActivationTests(TestCase): -- cgit v1.3