From: Kristi Tsukida Date: Thu, 12 Jul 2012 20:38:11 +0000 (-0700) Subject: fix tests since lstrip_blocks strips comments X-Git-Tag: 2.7~48^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=523efbdf6145f0b39eb03add87ab515f3e184b24;p=thirdparty%2Fjinja.git fix tests since lstrip_blocks strips comments --- diff --git a/jinja2/testsuite/lexnparse.py b/jinja2/testsuite/lexnparse.py index 5525f558..a2d33074 100644 --- a/jinja2/testsuite/lexnparse.py +++ b/jinja2/testsuite/lexnparse.py @@ -419,10 +419,8 @@ class LstripBlocksTestCase(JinjaTestCase): def test_lstrip_embeded_strings(self): env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string(''' {% if "{% str %}" %} -hello -{% endif %}''') - assert tmpl.render() == '\nhello\n' + tmpl = env.from_string(''' {% set x = " {% str %} " %}{{ x }}''') + assert tmpl.render() == ' {% str %} ' def test_lstrip_preserve_leading_newlines(self): env = Environment(lstrip_blocks=True, trim_blocks=False) @@ -434,7 +432,7 @@ hello tmpl = env.from_string(''' {# if True #} hello {#endif#}''') - assert tmpl.render() == ' \nhello\n ' + assert tmpl.render() == '\nhello\n' def test_lstrip_angle_bracket_simple(self): env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', @@ -445,9 +443,8 @@ hello def test_lstrip_angle_bracket_comment(self): env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string('''\ - <%# if True %>hello<%# endif %>''') - assert tmpl.render() == ' hello' + tmpl = env.from_string(''' <%# if True %>hello <%# endif %>''') + assert tmpl.render() == 'hello ' def test_lstrip_angle_bracket(self): env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', @@ -458,7 +455,7 @@ hello ${item} ## the rest of the stuff <% endfor %>''') assert tmpl.render(seq=range(5)) == \ - ' ' + ''.join('%s\n' % x for x in range(5)) + ''.join('%s\n' % x for x in range(5)) def test_lstrip_angle_bracket_compact(self): env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', @@ -469,13 +466,13 @@ ${item} ## the rest of the stuff ${item} ## the rest of the stuff <%endfor%>''') assert tmpl.render(seq=range(5)) == \ - ' ' + ''.join('%s\n' % x for x in range(5)) + ''.join('%s\n' % x for x in range(5)) def test_php_syntax_with_manual(self): env = Environment('', '', '', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string('''\ - + ''') @@ -489,7 +486,7 @@ ${item} ## the rest of the stuff ''') - assert tmpl.render(seq=range(5)) == ' ' + ''.join(' %s\n' % x for x in range(5)) + assert tmpl.render(seq=range(5)) == ''.join(' %s\n' % x for x in range(5)) def test_php_syntax_compact(self): env = Environment('', '', '', @@ -499,7 +496,7 @@ ${item} ## the rest of the stuff ''') - assert tmpl.render(seq=range(5)) == ' ' + ''.join(' %s\n' % x for x in range(5)) + assert tmpl.render(seq=range(5)) == ''.join(' %s\n' % x for x in range(5)) def test_erb_syntax(self): env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>',