From: Armin Ronacher Date: Sun, 14 Mar 2010 23:42:27 +0000 (+0100) Subject: More testcaseeees :) X-Git-Tag: 2.4~17 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d7c765de5465ad962e4b12cdfe27f4c5579384bb;p=jinja2.git More testcaseeees :) --HG-- branch : trunk --- 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():