Skip to content
Myr

Cleaned up shitty syntax in testsuite

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

authored by Armin Ronacher · committed by Armin Ronacher · parent cb4b551 · Browse files · 11 files+29 added−29 removed
This commit

State

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

Diff stats

11 files+29 added−29 removed

  • tests:+29 added−29 removed

11 files+29 added−29 removed

modified:tests/test_api.py+5 added-5 removed
21 unmodified lines
222324@pytest.mark.api25@pytest.mark.extended26class TestExtendedAPI():26class TestExtendedAPI(object):2728 def test_item_and_attribute(self, env):29 from jinja2.sandbox import SandboxedEnvironment30
75 unmodified lines
106107108@pytest.mark.api109@pytest.mark.meta110class TestMeta():110class TestMeta(object):111112 def test_find_undeclared_variables(self, env):113 ast = env.parse('{% set foo = 42 %}{{ bar + foo }}')114 x = meta.find_undeclared_variables(ast)
39 unmodified lines
154155156@pytest.mark.api157@pytest.mark.streaming158class TestStreaming():158class TestStreaming(object):159160 def test_basic_streaming(self, env):161 tmpl = env.from_string("<ul>{% for item in seq %}<li>{{ loop.index "162 "}} - {{ item }}</li>{%- endfor %}</ul>")
35 unmodified lines
198199200@pytest.mark.api201@pytest.mark.undefined202class TestUndefined():202class TestUndefined(object):203204 def test_stopiteration_is_undefined(self):205 def test():206 raise StopIteration()
101 unmodified lines
308309310@pytest.mark.api311@pytest.mark.lowlevel312class TestLowLevel():312class TestLowLevel(object):313314 def test_custom_code_generator(self):315 class CustomCodeGenerator(CodeGenerator):316 def visit_Const(self, node, frame=None):
24 unmodified lines
modified:tests/test_bytecode_cache.py+1 added-1 removed
22 unmodified lines
23 )242526@pytest.mark.byte_code_cache27class TestByteCodeCache():27class TestByteCodeCache(object):2829 def test_simple(self, env):30 tmpl = env.get_template('test.html')31 assert tmpl.render().strip() == 'BAR'
1 unmodified line
modified:tests/test_ext.py+4 added-4 removed
158 unmodified lines
159 yield Token(lineno, 'data', token.value[pos:])160161162@pytest.mark.ext163class TestExtensions():163class TestExtensions(object):164165 def test_extend_late(self):166 env = Environment()167 env.add_extension('jinja2.ext.autoescape')
77 unmodified lines
245 assert ext[1].__class__ is T2246247248@pytest.mark.ext249class TestInternationalization():249class TestInternationalization(object):250251 def test_trans(self):252 tmpl = i18n_env.get_template('child.html')253 assert tmpl.render(LANGUAGE='de') == '<title>fehlend</title>pass auf'
60 unmodified lines
314 ]315316317@pytest.mark.ext318class TestNewstyleInternationalization():318class TestNewstyleInternationalization(object):319320 def test_trans(self):321 tmpl = newstyle_i18n_env.get_template('child.html')322 assert tmpl.render(LANGUAGE='de') == '<title>fehlend</title>pass auf'
73 unmodified lines
396 assert t.render() == '%(foo)s'397398399@pytest.mark.ext400class TestAutoEscape():400class TestAutoEscape(object):401402 def test_scoped_setting(self):403 env = Environment(extensions=['jinja2.ext.autoescape'],404 autoescape=True)
71 unmodified lines
modified:tests/test_imports.py+2 added-2 removed
24 unmodified lines
25 return env262728@pytest.mark.imports29class TestImports():29class TestImports(object):3031 def test_context_imports(self, test_env):32 t = test_env.from_string('{% import "module" as m %}{{ m.test() }}')33 assert t.render(foo=42) == '[|23]'
39 unmodified lines
737475@pytest.mark.imports76@pytest.mark.includes77class TestIncludes():77class TestIncludes(object):7879 def test_context_include(self, test_env):80 t = test_env.from_string('{% include "header" %}')81 assert t.render(foo=42) == '[42|23]'
75 unmodified lines
modified:tests/test_inheritance.py+2 added-2 removed
76 unmodified lines
77 }), trim_blocks=True)787980@pytest.mark.inheritance81class TestInheritance():81class TestInheritance(object):8283 def test_layout(self, env):84 tmpl = env.get_template('layout')85 assert tmpl.render() == ('|block 1 from layout|block 2 from '
114 unmodified lines
200 assert rv == ['43', '44', '45']201202203@pytest.mark.inheritance204class TestBugFix():204class TestBugFix(object):205206 def test_fixed_macro_scoping_bug(self, env):207 assert Environment(loader=DictLoader({208 'test.html': '''\
40 unmodified lines
modified:tests/test_lexnparse.py+5 added-5 removed
25 unmodified lines
262728@pytest.mark.lexnparse29@pytest.mark.tokenstream30class TestTokenStream():30class TestTokenStream(object):31 test_tokens = [Token(1, TOKEN_BLOCK_BEGIN, ''),32 Token(2, TOKEN_BLOCK_END, ''),33 ]34
19 unmodified lines
545556@pytest.mark.lexnparse57@pytest.mark.lexer58class TestLexer():58class TestLexer(object):5960 def test_raw1(self, env):61 tmpl = env.from_string(62 '{% raw %}foo{% endraw %}|'
65 unmodified lines
128129130@pytest.mark.lexnparse131@pytest.mark.parser132class TestParser():132class TestParser(object):133134 def test_php_syntax(self, env):135 env = Environment('<?', '?>', '<?=', '?>', '<!--', '-->')136 tmpl = env.from_string('''\
108 unmodified lines
245246247@pytest.mark.lexnparse248@pytest.mark.syntax249class TestSyntax():249class TestSyntax(object):250251 def test_call(self, env):252 env = Environment()253 env.globals['foo'] = lambda a, b, c, e, g: a + b + c + e + g
187 unmodified lines
441442443@pytest.mark.lexnparse444@pytest.mark.lstripblocks445class TestLstripBlocks():445class TestLstripBlocks(object):446447 def test_lstrip(self, env):448 env = Environment(lstrip_blocks=True, trim_blocks=False)449 tmpl = env.from_string(''' {% if True %}\n {% endif %}''')
164 unmodified lines
modified:tests/test_loader.py+2 added-2 removed
20 unmodified lines
21from jinja2.exceptions import TemplateNotFound222324@pytest.mark.loaders25class TestLoaders():25class TestLoaders(object):2627 def test_dict_loader(self, dict_loader):28 env = Environment(loader=dict_loader)29 tmpl = env.get_template('justdict.html')
90 unmodified lines
120121122@pytest.mark.loaders123@pytest.mark.moduleloader124class TestModuleLoader():124class TestModuleLoader(object):125 archive = None126127 def compile_down(self, prefix_loader, zip='deflated', py_compile=False):128 log = []
106 unmodified lines
modified:tests/test_regression.py+2 added-2 removed
15 unmodified lines
16from jinja2._compat import text_type171819@pytest.mark.regression20class TestCorner():20class TestCorner(object):2122 def test_assigned_scoping(self, env):23 t = env.from_string('''24 {%- for item in (1, 2, 3, 4) -%}
52 unmodified lines
77 assert t.render(wrapper=23) == '[1][2][3][4]23'787980@pytest.mark.regression81class TestBug():81class TestBug(object):8283 def test_keyword_folding(self, env):84 env = Environment()85 env.filters['testing'] = lambda value, some: value + some
252 unmodified lines
modified:tests/test_security.py+1 added-1 removed
40 unmodified lines
41 return 'PublicStuff'424344@pytest.mark.sandbox45class TestSandbox():45class TestSandbox(object):4647 def test_unsafe(self, env):48 env = SandboxedEnvironment()49 pytest.raises(SecurityError, env.from_string("{{ foo.foo() }}").render,
141 unmodified lines
modified:tests/test_tests.py+1 added-1 removed
12 unmodified lines
13from jinja2 import Markup, Environment141516@pytest.mark.test_tests17class TestTestsCase():17class TestTestsCase(object):1819 def test_defined(self, env):20 tmpl = env.from_string('{{ missing is defined }}|'21 '{{ true is defined }}')
93 unmodified lines
modified:tests/test_utils.py+4 added-4 removed
17 unmodified lines
181920@pytest.mark.utils21@pytest.mark.lrucache22class TestLRUCache():22class TestLRUCache(object):2324 def test_simple(self):25 d = LRUCache(3)26 d["a"] = 1
18 unmodified lines
454647@pytest.mark.utils48@pytest.mark.helpers49class TestHelpers():49class TestHelpers(object):5051 def test_object_type_repr(self):52 class X(object):53 pass
7 unmodified lines
61@pytest.mark.utils62@pytest.mark.markupleak63@pytest.mark.skipif(hasattr(escape, 'func_code'),64 reason='this test only tests the c extension')65class TestMarkupLeak():65class TestMarkupLeak(object):6667 def test_markup_leaks(self):68 counts = set()69 for count in range(20):
7 unmodified lines
777879@pytest.mark.utils80@pytest.mark.escapeUrlizeTarget81class TestEscapeUrlizeTarget():81class TestEscapeUrlizeTarget(object):82 def test_escape_urlize_target(self):83 url = "http://example.org"84 target = "<script>"85 assert urlize(url, target=target) == ('<a href="http://example.org"'
2 unmodified lines