Skip to content
Myr

Added new testcase

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 4f77a30 · Browse files · 2 files+10 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−2 removed

  • other:+10 added−2 removed

2 files+10 added−2 removed

modified:jinja2/testsuite/ext.py+9 added-1 removed
52 unmodified lines
53 'ngettext_long.html': '{% trans num=apples %}{{ num }} apple{% pluralize %}'54 '{{ num }} apples{% endtrans %}',55 'transvars1.html': '{% trans %}User: {{ num }}{% endtrans %}',56 'transvars2.html': '{% trans num=count %}User: {{ num }}{% endtrans %}',57 'transvars3.html': '{% trans count=num %}User: {{ count }}{% endtrans %}'57 'transvars3.html': '{% trans count=num %}User: {{ count }}{% endtrans %}',58 'novars.html': '{% trans %}%(hello)s{% endtrans %}',59 'vars.html': '{% trans %}{{ foo }}%(foo)s{% endtrans %}'60}616263languages = {
294 unmodified lines
358 assert t1.render(num=1, LANGUAGE='de') == 'Benutzer: 1'359 assert t2.render(count=23, LANGUAGE='de') == 'Benutzer: 23'360 assert t3.render(num=42, LANGUAGE='de') == 'Benutzer: 42'361362 def test_novars_vars_escaping(self):363 t = newstyle_i18n_env.get_template('novars.html')364 assert t.render() == '%(hello)s'365 t = newstyle_i18n_env.get_template('vars.html')366 assert t.render(foo='42') == '42%(foo)s'367368369class AutoEscapeTestCase(JinjaTestCase):370371 def test_scoped_setting(self):372 env = Environment(extensions=['jinja2.ext.autoescape'],
80 unmodified lines
modified:jinja2/ext.py+1 added-1 removed
325 unmodified lines
326 def _make_node(self, singular, plural, variables, plural_expr,327 vars_referenced, num_called_num):328 """Generates a useful node from the data provided."""329 # no variables referenced? no need to escape for old style330 # gettext invocations330 # gettext invocations only if there are vars.331 if not vars_referenced and not self.environment.newstyle_gettext:332 singular = singular.replace('%%', '%')333 if plural:334 plural = plural.replace('%%', '%')
276 unmodified lines