More testcaseeees :)
authorArmin Ronacher <armin.ronacher@active-4.com>
Sun, 14 Mar 2010 23:42:27 +0000 (00:42 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sun, 14 Mar 2010 23:42:27 +0000 (00:42 +0100)
--HG--
branch : trunk

jinja2/testsuite/ext.py

index f8458b1f381e9cdf4dc2a0a4f1af62fc72bf4a39..ac273b9887766bf2a919c386e45851e86c653582 100644 (file)
@@ -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__
+        {{ '<testing>' }}
+        '''
+        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 <testing> there in raw
+        # (and then escaped as well)
+        env = Environment(extensions=['jinja2.ext.autoescape'])
+        pysource = env.compile(tmplsource, raw=True)
+        assert '<testing>\\n' in pysource
+
+        env = Environment(extensions=['jinja2.ext.autoescape'],
+                          autoescape=True)
+        pysource = env.compile(tmplsource, raw=True)
+        assert '&lt;testing&gt;\\n' in pysource
 
 
 def suite():