Skip to content
Myr

fix tests since lstrip_blocks strips comments

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

authored by Kristi Tsukida · committed by Kristi Tsukida · parent 54f7d2e · Browse files · 1 file+10 added−13 removed
This commit

State

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

Diff stats

1 file+10 added−13 removed

  • other:+10 added−13 removed

1 file+10 added−13 removed

modified:jinja2/testsuite/lexnparse.py+10 added-13 removed
417 unmodified lines
418 assert tmpl.render() == ' abc \n hello'419420 def test_lstrip_embeded_strings(self):421 env = Environment(lstrip_blocks=True, trim_blocks=False)422 tmpl = env.from_string(''' {% if "{% str %}" %}423hello424{% endif %}''')425 assert tmpl.render() == '\nhello\n'422 tmpl = env.from_string(''' {% set x = " {% str %} " %}{{ x }}''')423 assert tmpl.render() == ' {% str %} '424425 def test_lstrip_preserve_leading_newlines(self):426 env = Environment(lstrip_blocks=True, trim_blocks=False)427 tmpl = env.from_string('''\n\n\n{% set hello = 1 %}''')
3 unmodified lines
431 env = Environment(lstrip_blocks=True, trim_blocks=False)432 tmpl = env.from_string(''' {# if True #}433hello434 {#endif#}''')437 assert tmpl.render() == ' \nhello\n '435 assert tmpl.render() == '\nhello\n'436437 def test_lstrip_angle_bracket_simple(self):438 env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##',439 lstrip_blocks=True, trim_blocks=True)
2 unmodified lines
442443 def test_lstrip_angle_bracket_comment(self):444 env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##',445 lstrip_blocks=True, trim_blocks=True)448 tmpl = env.from_string('''\449 <%# if True %>hello<%# endif %>''')450 assert tmpl.render() == ' hello'446 tmpl = env.from_string(''' <%# if True %>hello <%# endif %>''')447 assert tmpl.render() == 'hello '448449 def test_lstrip_angle_bracket(self):450 env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##',451 lstrip_blocks=True, trim_blocks=True)
2 unmodified lines
454 <% for item in seq %>455${item} ## the rest of the stuff456 <% endfor %>''')457 assert tmpl.render(seq=range(5)) == \461 ' ' + ''.join('%s\n' % x for x in range(5))458 ''.join('%s\n' % x for x in range(5))459 460 def test_lstrip_angle_bracket_compact(self):461 env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##',462 lstrip_blocks=True, trim_blocks=True)
2 unmodified lines
465 <%for item in seq%>466${item} ## the rest of the stuff467 <%endfor%>''')468 assert tmpl.render(seq=range(5)) == \472 ' ' + ''.join('%s\n' % x for x in range(5))469 ''.join('%s\n' % x for x in range(5))470 471 def test_php_syntax_with_manual(self):472 env = Environment('<?', '?>', '<?=', '?>', '<!--', '-->',473 lstrip_blocks=True, trim_blocks=True)474 tmpl = env.from_string('''\478<!-- I'm a comment, I'm not interesting -->475 <!-- I'm a comment, I'm not interesting -->476 <? for item in seq -?>477 <?= item ?>478 <?- endfor ?>''')479 assert tmpl.render(seq=range(5)) == '01234'
5 unmodified lines
485 <!-- I'm a comment, I'm not interesting -->486 <? for item in seq ?>487 <?= item ?>488 <? endfor ?>''')492 assert tmpl.render(seq=range(5)) == ' ' + ''.join(' %s\n' % x for x in range(5))489 assert tmpl.render(seq=range(5)) == ''.join(' %s\n' % x for x in range(5))490491 def test_php_syntax_compact(self):492 env = Environment('<?', '?>', '<?=', '?>', '<!--', '-->',493 lstrip_blocks=True, trim_blocks=True)
1 unmodified line
495 <!-- I'm a comment, I'm not interesting -->496 <?for item in seq?>497 <?=item?>498 <?endfor?>''')502 assert tmpl.render(seq=range(5)) == ' ' + ''.join(' %s\n' % x for x in range(5))499 assert tmpl.render(seq=range(5)) == ''.join(' %s\n' % x for x in range(5))500501 def test_erb_syntax(self):502 env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>',503 lstrip_blocks=True, trim_blocks=True)
50 unmodified lines