From af1893c4ff8fdbf227a43a559d90bb1c1238b01a Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Tue, 1 Nov 2011 14:02:31 +0000 Subject: Made the cache locale-dependant when USE_L10N is True, even if USE_I18N is False. Refs #5691. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17061 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/cache/tests.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'tests/regressiontests/cache') diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py index bc0a05e4fe..e6c03837d4 100644 --- a/tests/regressiontests/cache/tests.py +++ b/tests/regressiontests/cache/tests.py @@ -1154,23 +1154,33 @@ class CacheI18nTest(TestCase): request.session = {} return request - @override_settings(USE_I18N=True) - def test_cache_key_i18n(self): + @override_settings(USE_I18N=True, USE_L10N=False) + def test_cache_key_i18n_translation(self): request = self._get_request() lang = translation.get_language() response = HttpResponse() key = learn_cache_key(request, response) - self.assertTrue(key.endswith(lang), "Cache keys should include the language name when i18n is active") + self.assertIn(lang, key, "Cache keys should include the language name when translation is active") key2 = get_cache_key(request) self.assertEqual(key, key2) - @override_settings(USE_I18N=False) + @override_settings(USE_I18N=False, USE_L10N=True) + def test_cache_key_i18n_formatting(self): + request = self._get_request() + lang = translation.get_language() + response = HttpResponse() + key = learn_cache_key(request, response) + self.assertIn(lang, key, "Cache keys should include the language name when formatting is active") + key2 = get_cache_key(request) + self.assertEqual(key, key2) + + @override_settings(USE_I18N=False, USE_L10N=False) def test_cache_key_no_i18n (self): request = self._get_request() lang = translation.get_language() response = HttpResponse() key = learn_cache_key(request, response) - self.assertFalse(key.endswith(lang), "Cache keys shouldn't include the language name when i18n is inactive") + self.assertNotIn(lang, key, "Cache keys shouldn't include the language name when i18n isn't active") @override_settings( CACHE_MIDDLEWARE_KEY_PREFIX="test", -- cgit v1.3