Code

Ticket #17197: fix_testsuite_translation_leakage.diff

File fix_testsuite_translation_leakage.diff, 2.1 KB (added by apollo13, 2 years ago)
Line 
1diff --git a/tests/regressiontests/views/tests/i18n.py b/tests/regressiontests/views/tests/i18n.py
2index 2f67d52..f13f7d1 100644
3--- a/tests/regressiontests/views/tests/i18n.py
4+++ b/tests/regressiontests/views/tests/i18n.py
5@@ -6,7 +6,7 @@ from os import path
6 
7 from django.conf import settings
8 from django.test import TestCase
9-from django.utils.translation import override, activate
10+from django.utils.translation import override
11 from django.utils.text import javascript_quote
12 
13 from ..urls import locale_dir
14@@ -26,17 +26,17 @@ class I18NTests(TestCase):
15     def test_jsi18n(self):
16         """The javascript_catalog can be deployed with language settings"""
17         for lang_code in ['es', 'fr', 'ru']:
18-            activate(lang_code)
19-            catalog = gettext.translation('djangojs', locale_dir, [lang_code])
20-            trans_txt = catalog.ugettext('this is to be translated')
21-            response = self.client.get('/views/jsi18n/')
22-            # in response content must to be a line like that:
23-            # catalog['this is to be translated'] = 'same_that_trans_txt'
24-            # javascript_quote is used to be able to check unicode strings
25-            self.assertContains(response, javascript_quote(trans_txt), 1)
26-            if lang_code == 'fr':
27-                # Message with context (msgctxt)
28-                self.assertContains(response, "['month name\x04May'] = 'mai';", 1)
29+            with override(lang_code):
30+                catalog = gettext.translation('djangojs', locale_dir, [lang_code])
31+                trans_txt = catalog.ugettext('this is to be translated')
32+                response = self.client.get('/views/jsi18n/')
33+                # in response content must to be a line like that:
34+                # catalog['this is to be translated'] = 'same_that_trans_txt'
35+                # javascript_quote is used to be able to check unicode strings
36+                self.assertContains(response, javascript_quote(trans_txt), 1)
37+                if lang_code == 'fr':
38+                    # Message with context (msgctxt)
39+                    self.assertContains(response, "['month name\x04May'] = 'mai';", 1)
40 
41 
42 class JsI18NTests(TestCase):