Ticket #11240: 11240-test.diff

File 11240-test.diff, 1.8 KB (added by Claude Paroz, 12 years ago)

Test showing different behaviour between trans and blocktrans

  • tests/i18n/commands/compilation.py

    diff --git a/tests/i18n/commands/compilation.py b/tests/i18n/commands/compilation.py
    index 12bb89e..8b244f5 100644
    a b class PercentRenderingTests(MessageCompilationTests):  
    6565        from django.template import Template, Context
    6666        call_command('compilemessages', locale=self.LOCALE, stdout=StringIO())
    6767        with translation.override(self.LOCALE):
    68             t = Template('{% load i18n %}{% trans "Looks like a str fmt spec %% o but shouldn\'t be interpreted as such" %}')
    69             rendered = t.render(Context({}))
    70             self.assertEqual(rendered, 'IT translation contains %% for the above string')
    71 
    72             t = Template('{% load i18n %}{% trans "Completed 50%% of all the tasks" %}')
    73             rendered = t.render(Context({}))
    74             self.assertEqual(rendered, 'IT translation of Completed 50%% of all the tasks')
     68            t1 = Template('{% load i18n %}{% trans "Looks like a str fmt spec % o but shouldn\'t be interpreted as such" %}')
     69            t2 = Template('{% load i18n %}{% blocktrans %}Looks like a str fmt spec % o but shouldn\'t be interpreted as such{% endblocktrans %}')
     70            for templ in (t1, t2):
     71                rendered = templ.render(Context({}))
     72                self.assertEqual(rendered, 'IT translation contains % for the above string')
     73
     74            t1 = Template('{% load i18n %}{% trans "Completed 50% of all the tasks" %}')
     75            t2 = Template('{% load i18n %}{% blocktrans %}Completed 50% of all the tasks{% endblocktrans %}')
     76            for templ in (t1, t2):
     77                rendered = t.render(Context({}))
     78                self.assertEqual(rendered, 'IT translation of Completed 50% of all the tasks')
    7579
    7680
    7781@override_settings(LOCALE_PATHS=(os.path.join(test_dir, 'locale'),))
Back to Top