Skip to content
Myr

Make tests pass on older python versions again

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 acab87a · Browse files · 2 files+7 added−11 removed
This commit

State

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

Diff stats

2 files+7 added−11 removed

  • tests:+7 added−11 removed

2 files+7 added−11 removed

modified:tests/conftest.py+7 added
14 unmodified lines
1516from traceback import format_exception17from jinja2 import loaders18from jinja2._compat import PY219from jinja2.utils import have_async_gen20from jinja2 import Environment212223def pytest_ignore_collect(path, config):24 if path.basename == 'test_async.py' and not have_async_gen:25 return True26 return False272829@pytest.fixture30def env():31 '''returns a new environment.32 '''
49 unmodified lines
modified:tests/test_async.py-11 removed
10 unmodified lines
11 loop = asyncio.get_event_loop()12 return loop.run_until_complete(coro)131415@pytest.mark.skipif(not have_async_gen, reason='No async generators')15def test_basic_async():16 t = Template('{% for item in [1, 2, 3] %}[{{ item }}]{% endfor %}',17 enable_async=True)18 async def func():
2 unmodified lines
21 rv = run(func())22 assert rv == '[1][2][3]'232426@pytest.mark.skipif(not have_async_gen, reason='No async generators')25def test_await_on_calls():26 t = Template('{{ async_func() + normal_func() }}',27 enable_async=True)28
12 unmodified lines
41 rv = run(func())42 assert rv == '65'434447@pytest.mark.skipif(not have_async_gen, reason='No async generators')45def test_await_on_calls_normal_render():46 t = Template('{{ async_func() + normal_func() }}',47 enable_async=True)48
10 unmodified lines
5960 assert rv == '65'616266@pytest.mark.skipif(not have_async_gen, reason='No async generators')63def test_await_and_macros():64 t = Template('{% macro foo(x) %}[{{ x }}][{{ async_func() }}]'65 '{% endmacro %}{{ foo(42) }}', enable_async=True)66
6 unmodified lines
73 rv = run(func())74 assert rv == '[42][42]'757681@pytest.mark.skipif(not have_async_gen, reason='No async generators')77def test_async_blocks():78 t = Template('{% block foo %}<Test>{% endblock %}{{ self.foo() }}',79 enable_async=True, autoescape=True)80 async def func():
2 unmodified lines
83 rv = run(func())84 assert rv == '<Test><Test>'858692@pytest.mark.skipif(not have_async_gen, reason='No async generators')87def test_async_generate():88 t = Template('{% for x in [1, 2, 3] %}{{ x }}{% endfor %}',89 enable_async=True)90 rv = list(t.generate())91 assert rv == ['1', '2', '3']9293100@pytest.mark.skipif(not have_async_gen, reason='No async generators')94def test_async_iteration_in_templates():95 t = Template('{% for x in rng %}{{ x }}{% endfor %}',96 enable_async=True)97 async def async_iterator():
2 unmodified lines
100 rv = list(t.generate(rng=async_iterator()))101 assert rv == ['1', '2', '3']102103111@pytest.mark.skipif(not have_async_gen, reason='No async generators')104def test_async_iteration_in_templates_extended():105 t = Template('{% for x in rng %}{{ loop.index0 }}/{{ x }}{% endfor %}',106 enable_async=True)107 async def async_iterator():
13 unmodified lines
121 env.globals['bar'] = 23122 return env123124133@pytest.mark.skipif(not have_async_gen, reason='No async generators')125@pytest.mark.imports126class TestAsyncImports(object):127128 def test_context_imports(self, test_env_async):
39 unmodified lines
168 assert m.variable == 42169 assert not hasattr(m, 'notthere')170171181@pytest.mark.skipif(not have_async_gen, reason='No async generators')172@pytest.mark.imports173@pytest.mark.includes174class TestAsyncIncludes(object):175
68 unmodified lines
244 """)245 assert t.render().strip() == '(FOO)'246247258@pytest.mark.skipif(not have_async_gen, reason='No async generators')248@pytest.mark.core_tags249@pytest.mark.for_loop250class TestAsyncForLoop(object):251
167 unmodified lines