Ticket #17197: fix_testsuite_translation_leakage.diff

File fix_testsuite_translation_leakage.diff, 2.1 KB (added by Florian Apolloner, 13 years ago)
  • tests/regressiontests/views/tests/i18n.py

    diff --git a/tests/regressiontests/views/tests/i18n.py b/tests/regressiontests/views/tests/i18n.py
    index 2f67d52..f13f7d1 100644
    a b from os import path  
    66
    77from django.conf import settings
    88from django.test import TestCase
    9 from django.utils.translation import override, activate
     9from django.utils.translation import override
    1010from django.utils.text import javascript_quote
    1111
    1212from ..urls import locale_dir
    class I18NTests(TestCase):  
    2626    def test_jsi18n(self):
    2727        """The javascript_catalog can be deployed with language settings"""
    2828        for lang_code in ['es', 'fr', 'ru']:
    29             activate(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)
     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)
    4040
    4141
    4242class JsI18NTests(TestCase):
Back to Top