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
Provenance
- Commit
7265e6f- Tree
3d90191- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
acab87a
2 files changed+7 added−11 removed
modified:tests/conftest.py+7 added
14 unmodified lines15 16 from traceback import format_exception17 from jinja2 import loaders18 from jinja2._compat import PY219+from jinja2.utils import have_async_gen20 from jinja2 import Environment21 22 23+def pytest_ignore_collect(path, config):24+ if path.basename == 'test_async.py' and not have_async_gen:25+ return True26+ return False27+28+29 @pytest.fixture30 def env():31 '''returns a new environment.32 '''49 unmodified linesmodified:tests/test_async.py-11 removed
10 unmodified lines11 loop = asyncio.get_event_loop()12 return loop.run_until_complete(coro)13 14 15-@pytest.mark.skipif(not have_async_gen, reason='No async generators')15 def test_basic_async():16 t = Template('{% for item in [1, 2, 3] %}[{{ item }}]{% endfor %}',17 enable_async=True)18 async def func():2 unmodified lines21 rv = run(func())22 assert rv == '[1][2][3]'23 24 26-@pytest.mark.skipif(not have_async_gen, reason='No async generators')25 def test_await_on_calls():26 t = Template('{{ async_func() + normal_func() }}',27 enable_async=True)28 12 unmodified lines41 rv = run(func())42 assert rv == '65'43 44 47-@pytest.mark.skipif(not have_async_gen, reason='No async generators')45 def test_await_on_calls_normal_render():46 t = Template('{{ async_func() + normal_func() }}',47 enable_async=True)48 10 unmodified lines59 60 assert rv == '65'61 62 66-@pytest.mark.skipif(not have_async_gen, reason='No async generators')63 def test_await_and_macros():64 t = Template('{% macro foo(x) %}[{{ x }}][{{ async_func() }}]'65 '{% endmacro %}{{ foo(42) }}', enable_async=True)66 6 unmodified lines73 rv = run(func())74 assert rv == '[42][42]'75 76 81-@pytest.mark.skipif(not have_async_gen, reason='No async generators')77 def test_async_blocks():78 t = Template('{% block foo %}<Test>{% endblock %}{{ self.foo() }}',79 enable_async=True, autoescape=True)80 async def func():2 unmodified lines83 rv = run(func())84 assert rv == '<Test><Test>'85 86 92-@pytest.mark.skipif(not have_async_gen, reason='No async generators')87 def 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']92 93 100-@pytest.mark.skipif(not have_async_gen, reason='No async generators')94 def 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 lines100 rv = list(t.generate(rng=async_iterator()))101 assert rv == ['1', '2', '3']102 103 111-@pytest.mark.skipif(not have_async_gen, reason='No async generators')104 def 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 lines121 env.globals['bar'] = 23122 return env123 124 133-@pytest.mark.skipif(not have_async_gen, reason='No async generators')125 @pytest.mark.imports126 class TestAsyncImports(object):127 128 def test_context_imports(self, test_env_async):39 unmodified lines168 assert m.variable == 42169 assert not hasattr(m, 'notthere')170 171 181-@pytest.mark.skipif(not have_async_gen, reason='No async generators')172 @pytest.mark.imports173 @pytest.mark.includes174 class TestAsyncIncludes(object):175 68 unmodified lines244 """)245 assert t.render().strip() == '(FOO)'246 247 258-@pytest.mark.skipif(not have_async_gen, reason='No async generators')248 @pytest.mark.core_tags249 @pytest.mark.for_loop250 class TestAsyncForLoop(object):251 167 unmodified lines