test_debug.py
This file
Path
tests/test_debug.py
51 lines · 1.2 KiB · Python
Last changed by
Got rid of py.testisms.Armin Ronacherbefore adoption42979eb
History of this fileTake it
even more tests, fixed severe bug with autoescaping.Armin Ronacherbefore adoption5411ce7
lines 1–7why, one step back1# -*- coding: utf-8 -*-2"""3 Test debug interface4 ~~~~~~~~~~~~~~~~~~~~56 Tests the traceback rewriter.7Copyright switch to "The Jinja Team".Armin Ronacherbefore adoption62ccd1b
line 8why, one step back8 :copyright: (c) 2009 by the Jinja Team.even more tests, fixed severe bug with autoescaping.Armin Ronacherbefore adoption5411ce7
lines 9–16why, one step back9 :license: BSD.10"""11from jinja2 import Environment12from test_loaders import filesystem_loader1314env = Environment(loader=filesystem_loader)1516merged.Armin Ronacherbefore adoption1b43b58
lines 17–18why, one step back17def test_runtime_error():18 '''Got rid of py.testisms.Armin Ronacherbefore adoption42979eb
line 19why, one step back19>>> tmpl = env.get_template('broken.html')even more tests, fixed severe bug with autoescaping.Armin Ronacherbefore adoption5411ce7
lines 20–29why, one step back20>>> tmpl.render(fail=lambda: 1 / 0)21Traceback (most recent call last):22 File "loaderres/templates/broken.html", line 2, in top-level template code23 {{ fail() }}24 File "<doctest test_runtime_error[1]>", line 1, in <lambda>25 tmpl.render(fail=lambda: 1 / 0)26ZeroDivisionError: integer division or modulo by zero27'''2829merged.Armin Ronacherbefore adoption1b43b58
lines 30–31why, one step back30def test_syntax_error():31 '''Got rid of py.testisms.Armin Ronacherbefore adoption42979eb
line 32why, one step back32>>> tmpl = env.get_template('syntaxerror.html')even more tests, fixed severe bug with autoescaping.Armin Ronacherbefore adoption5411ce7
lines 33–34why, one step back33Traceback (most recent call last):34 ...Improved Jinja's debugging support by introducing "@internalcode" which marks code objects that are skipped on tracebacks. Also template errors are now translated as well to help the pylons debugger.Armin Ronacherbefore adoptiond416a97
line 35why, one step back35TemplateSyntaxError: unknown tag 'endif'merged.Armin Ronacherbefore adoption1b43b58
lines 36–37why, one step back36 File "loaderres/templates\\syntaxerror.html", line 437 {% endif %}Improved Jinja's debugging support by introducing "@internalcode" which marks code objects that are skipped on tracebacks. Also template errors are now translated as well to help the pylons debugger.Armin Ronacherbefore adoptiond416a97
lines 38–40why, one step back38'''3940merged.Armin Ronacherbefore adoption1b43b58
lines 41–42why, one step back41def test_regular_syntax_error():42 '''Improved Jinja's debugging support by introducing "@internalcode" which marks code objects that are skipped on tracebacks. Also template errors are now translated as well to help the pylons debugger.Armin Ronacherbefore adoptiond416a97
lines 43–50why, one step back43>>> from jinja2.exceptions import TemplateSyntaxError44>>> raise TemplateSyntaxError('wtf', 42)45Traceback (most recent call last):46 ...47 File "<doctest test_regular_syntax_error[1]>", line 1, in <module>48 raise TemplateSyntaxError('wtf', 42)49TemplateSyntaxError: wtf50 line 42even more tests, fixed severe bug with autoescaping.Armin Ronacherbefore adoption5411ce7
line 51why, one step back51'''