From d7c765de5465ad962e4b12cdfe27f4c5579384bb Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 15 Mar 2010 00:42:27 +0100 Subject: [PATCH] More testcaseeees :) --HG-- branch : trunk --- jinja2/testsuite/ext.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/jinja2/testsuite/ext.py b/jinja2/testsuite/ext.py index f8458b1..ac273b9 100644 --- a/jinja2/testsuite/ext.py +++ b/jinja2/testsuite/ext.py @@ -308,16 +308,29 @@ class AutoEscapeTestCase(JinjaTestCase): def test_volatile_scoping(self): env = Environment(extensions=['jinja2.ext.autoescape']) - tmpl = env.from_string(''' + tmplsource = ''' {% autoescape val %} {% macro foo(x) %} [{{ x }}] {% endmacro %} {{ foo().__class__.__name__ }} {% endautoescape %} - ''') - assert tmpl.render(val=True).strip() == 'Markup' - assert tmpl.render(val=False).strip() == unicode.__name__ + {{ '' }} + ''' + tmpl = env.from_string(tmplsource) + assert tmpl.render(val=True).split()[0] == 'Markup' + assert tmpl.render(val=False).split()[0] == unicode.__name__ + + # looking at the source we should see there in raw + # (and then escaped as well) + env = Environment(extensions=['jinja2.ext.autoescape']) + pysource = env.compile(tmplsource, raw=True) + assert '\\n' in pysource + + env = Environment(extensions=['jinja2.ext.autoescape'], + autoescape=True) + pysource = env.compile(tmplsource, raw=True) + assert '<testing>\\n' in pysource def suite(): -- 2.26.2