test_tests.py
This file
Path
tests/test_tests.py
93 lines · 2.3 KiB · Python
Last changed by
Copyright switch to "The Jinja Team".Armin Ronacherbefore adoption62ccd1b
History of this fileTake it
The walk stopped after 200 commits: lines older than 374a05d point at it.
added intro text to doc indexArmin Ronacherbefore adoption374a05d
lines 1–5why, one step back1# -*- coding: utf-8 -*-2"""3 unit test for the test functions4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~5Copyright switch to "The Jinja Team".Armin Ronacherbefore adoption62ccd1b
line 6why, one step back6 :copyright: (c) 2009 by the Jinja Team.added intro text to doc indexArmin Ronacherbefore adoption374a05d
lines 7–8why, one step back7 :license: BSD, see LICENSE for more details.8"""added more unittests for various tasksArmin Ronacherbefore adoption9f258ff
line 9why, one step back9from jinja2 import Environment, Markupadded intro text to doc indexArmin Ronacherbefore adoption374a05d
line 10why, one step back10added more unittests for various tasksArmin Ronacherbefore adoption9f258ff
line 11why, one step back11added intro text to doc indexArmin Ronacherbefore adoption374a05d
lines 12–21why, one step back12DEFINED = '''{{ missing is defined }}|{{ true is defined }}'''13EVEN = '''{{ 1 is even }}|{{ 2 is even }}'''14LOWER = '''{{ "foo" is lower }}|{{ "FOO" is lower }}'''15ODD = '''{{ 1 is odd }}|{{ 2 is odd }}'''16SEQUENCE = '''{{ [1, 2, 3] is sequence }}|\17{{ "foo" is sequence }}|\18{{ 42 is sequence }}'''19UPPER = '''{{ "FOO" is upper }}|{{ "foo" is upper }}'''20SAMEAS = '''{{ foo is sameas false }}|{{ 0 is sameas false }}'''21NOPARENFORARG1 = '''{{ foo is sameas none }}'''added more unittests for various tasksArmin Ronacherbefore adoption9f258ff
lines 22–34why, one step back22TYPECHECKS = '''\23{{ 42 is undefined }}24{{ 42 is defined }}25{{ 42 is none }}26{{ none is none }}27{{ 42 is number }}28{{ 42 is string }}29{{ "foo" is string }}30{{ "foo" is sequence }}31{{ [1] is sequence }}32{{ range is callable }}33{{ 42 is callable }}34{{ range(5) is iterable }}'''added intro text to doc indexArmin Ronacherbefore adoption374a05d
lines 35–46why, one step back353637def test_defined(env):38 tmpl = env.from_string(DEFINED)39 assert tmpl.render() == 'False|True'404142def test_even(env):43 tmpl = env.from_string(EVEN)44 assert tmpl.render() == 'False|True'4546added more unittests for various tasksArmin Ronacherbefore adoption9f258ff
lines 47–51why, one step back47def test_odd(env):48 tmpl = env.from_string(ODD)49 assert tmpl.render() == 'True|False'5051added intro text to doc indexArmin Ronacherbefore adoption374a05d
lines 52–56why, one step back52def test_lower(env):53 tmpl = env.from_string(LOWER)54 assert tmpl.render() == 'True|False'5556added more unittests for various tasksArmin Ronacherbefore adoption9f258ff
lines 57–59why, one step back57def test_typechecks(env):58 tmpl = env.from_string(TYPECHECKS)59 assert tmpl.render() == ''added intro text to doc indexArmin Ronacherbefore adoption374a05d
lines 60–76why, one step back606162def test_sequence(env):63 tmpl = env.from_string(SEQUENCE)64 assert tmpl.render() == 'True|True|False'656667def test_upper(env):68 tmpl = env.from_string(UPPER)69 assert tmpl.render() == 'True|False'707172def test_sameas(env):73 tmpl = env.from_string(SAMEAS)74 assert tmpl.render(foo=False) == 'True|False'7576added more unittests for various tasksArmin Ronacherbefore adoption9f258ff
lines 77–84why, one step back77def test_typechecks(env):78 tmpl = env.from_string(TYPECHECKS)79 assert tmpl.render() == (80 'False\nTrue\nFalse\nTrue\nTrue\nFalse\n'81 'True\nTrue\nTrue\nTrue\nFalse\nTrue'82 )8384added intro text to doc indexArmin Ronacherbefore adoption374a05d
lines 85–87why, one step back85def test_no_paren_for_arg1(env):86 tmpl = env.from_string(NOPARENFORARG1)87 assert tmpl.render(foo=None) == 'True'added more unittests for various tasksArmin Ronacherbefore adoption9f258ff
lines 88–93why, one step back888990def test_escaped():91 env = Environment(autoescape=True)92 tmpl = env.from_string('{{ x is escaped }}|{{ y is escaped }}')93 assert tmpl.render(x='foo', y=Markup('foo')) == 'False|True'