diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-02-28 13:45:21 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-02-28 14:21:48 +0100 |
| commit | aa089b106b6cfc9a47cd54a0f9eb44bd44811ed9 (patch) | |
| tree | 46a3d222554d694b30ef415a36c3b1b7849d2109 /tests | |
| parent | 06de130dae8b7a6c95143077d7a82fab37da0bc0 (diff) | |
Fixed #5241 -- Kept active transalation in LocaleMiddleware.process_response.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i18n/tests.py | 23 | ||||
| -rw-r--r-- | tests/i18n/urls.py | 9 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index 4d06c85c97..3038c4813c 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1096,3 +1096,26 @@ class MultipleLocaleActivationTests(TestCase): t = Template("{% load i18n %}{% blocktrans %}No{% endblocktrans %}") with translation.override('nl'): self.assertEqual(t.render(Context({})), 'Nee') + + +@override_settings( + USE_I18N=True, + LANGUAGES=( + ('en', 'English'), + ('fr', 'French'), + ), + MIDDLEWARE_CLASSES=( + 'django.middleware.locale.LocaleMiddleware', + 'django.middleware.common.CommonMiddleware', + ), +) +class LocaleMiddlewareTests(TestCase): + + urls = 'i18n.urls' + + def test_streaming_response(self): + # Regression test for #5241 + response = self.client.get('/fr/streaming/') + self.assertContains(response, "Oui/Non") + response = self.client.get('/en/streaming/') + self.assertContains(response, "Yes/No") diff --git a/tests/i18n/urls.py b/tests/i18n/urls.py new file mode 100644 index 0000000000..c118265dab --- /dev/null +++ b/tests/i18n/urls.py @@ -0,0 +1,9 @@ +from __future__ import unicode_literals + +from django.conf.urls.i18n import i18n_patterns +from django.http import StreamingHttpResponse +from django.utils.translation import ugettext_lazy as _ + +urlpatterns = i18n_patterns('', + (r'^streaming/$', lambda r: StreamingHttpResponse([_("Yes"), "/", _("No")])), +) |
