Skip to content
Myr

Restore original render func for non async usage

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 2b4d44b · Browse files · 2 files+20 added−1 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+20 added−1 removed

  • tests:+19 added−0 removed
  • other:+1 added−1 removed

2 files+20 added−1 removed

modified:jinja2/asyncsupport.py+1 added-1 removed
32 unmodified lines
33 def render(self, *args, **kwargs):34 if not self.environment._async:35 return original_render(self, *args, **kwargs)36 loop = asyncio.get_event_loop()37 return loop.run_until_complete(self.render_async(self, *args, **kwargs))37 return loop.run_until_complete(self.render_async(*args, **kwargs))38 return render394041def wrap_block_reference_call(original_call):
36 unmodified lines
modified:tests/test_async.py+19 added
41 unmodified lines
42 assert rv == '65'434445@pytest.mark.skipif(not have_async_gen, reason='No async generators')46def test_await_on_calls_normal_render():47 t = Template('{{ async_func() + normal_func() }}',48 enable_async=True)4950 async def async_func():51 return 425253 def normal_func():54 return 235556 rv = t.render(57 async_func=async_func,58 normal_func=normal_func59 )6061 assert rv == '65'626364@pytest.mark.skipif(not have_async_gen, reason='No async generators')65def test_await_and_macros():66 t = Template('{% macro foo(x) %}[{{ x }}][{{ async_func() }}]'67 '{% endmacro %}{{ foo(42) }}', enable_async=True)68
19 unmodified lines