if not self.environment._async:
return original_render(self, *args, **kwargs)
loop = asyncio.get_event_loop()
- return loop.run_until_complete(self.render_async(self, *args, **kwargs))
+ return loop.run_until_complete(self.render_async(*args, **kwargs))
return render
assert rv == '65'
+@pytest.mark.skipif(not have_async_gen, reason='No async generators')
+def test_await_on_calls_normal_render():
+ t = Template('{{ async_func() + normal_func() }}',
+ enable_async=True)
+
+ async def async_func():
+ return 42
+
+ def normal_func():
+ return 23
+
+ rv = t.render(
+ async_func=async_func,
+ normal_func=normal_func
+ )
+
+ assert rv == '65'
+
+
@pytest.mark.skipif(not have_async_gen, reason='No async generators')
def test_await_and_macros():
t = Template('{% macro foo(x) %}[{{ x }}][{{ async_func() }}]'