From ee06689878e87e45d3c2402dd5e3bb3ba2a79bcf Mon Sep 17 00:00:00 2001 From: Krzysztof Urbaniak Date: Thu, 27 Oct 2016 15:31:15 +0200 Subject: [PATCH] Added additional tests for translation's get_language_from_path(). --- tests/i18n/tests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index 717150de0d..1e49565a8c 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1472,11 +1472,24 @@ class MiscTests(SimpleTestCase): r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'} self.assertEqual(g(r), 'zh-hans') + @override_settings( + LANGUAGES=[ + ('en', 'English'), + ('de', 'German'), + ('de-at', 'Austrian German'), + ('pl', 'Polish'), + ], + ) def test_get_language_from_path_real(self): g = trans_real.get_language_from_path self.assertEqual(g('/pl/'), 'pl') self.assertEqual(g('/pl'), 'pl') self.assertIsNone(g('/xyz/')) + self.assertEqual(g('/en/'), 'en') + self.assertEqual(g('/en-gb/'), 'en') + self.assertEqual(g('/de/'), 'de') + self.assertEqual(g('/de-at/'), 'de-at') + self.assertEqual(g('/de-ch/'), 'de') def test_get_language_from_path_null(self): from django.utils.translation.trans_null import get_language_from_path as g