Skip to content

Commit efc1128

Browse files
committed
Finally enable_async everywhere
1 parent 209f1b2 commit efc1128

File tree

5 files changed

+7
-31
lines changed

5 files changed

+7
-31
lines changed

aiohttp_jinja2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def render_string(template_name, request, context, *, app_key=APP_KEY):
6060
raise web.HTTPInternalServerError(reason=text, text=text)
6161
if request.get(REQUEST_CONTEXT_KEY):
6262
context = dict(request[REQUEST_CONTEXT_KEY], **context)
63-
text = yield from template.render(context)
63+
text = yield from template.render_async(context)
6464
return text
6565

6666

tests/test_async_enabled.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,5 @@
66

77

88
@asyncio.coroutine
9-
def test_func(loop, test_client):
10-
11-
@aiohttp_jinja2.template('tmpl.jinja2')
12-
@asyncio.coroutine
13-
def func(request):
14-
return {'head': 'HEAD', 'text': 'text'}
15-
16-
template = '<html><body><h1>{{head}}</h1>{{text}}</body></html>'
17-
18-
app = web.Application(loop=loop)
19-
aiohttp_jinja2.setup(
20-
app,
21-
loader=jinja2.DictLoader({
22-
'tmpl.jinja2': template
23-
}),
24-
)
25-
26-
app.router.add_route('*', '/', func)
27-
28-
client = yield from test_client(app)
29-
30-
resp = yield from client.get('/')
31-
assert 200 == resp.status
32-
txt = yield from resp.text()
33-
assert '<html><body><h1>HEAD</h1>text</body></html>' == txt
9+
def test_func(test_client, test_server):
10+
pass

tests/test_context_processors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def func(request):
2222
'tmpl.jinja2': ("foo: {{ foo }}, bar: {{ bar }}, "
2323
"path: {{ request.path }}")
2424
}),
25-
enable_async=False,
25+
enable_async=True,
2626
)
2727

2828
app['aiohttp_jinja2_context_processors'] = (
@@ -76,7 +76,7 @@ def func(request):
7676
'tmpl.jinja2': template
7777
}),
7878
context_processors=(aiohttp_jinja2.request_processor, ctx_coro),
79-
enable_async=False,
79+
enable_async=True,
8080
)
8181

8282
app.router.add_route('GET', '/', func)
@@ -104,7 +104,7 @@ def func(request):
104104
app,
105105
loader=jinja2.DictLoader({'tmpl.jinja2': 'foo: {{ foo }}'}),
106106
context_processors=[ctx_coro],
107-
enable_async=False,
107+
enable_async=True,
108108
)
109109

110110
app.router.add_get('/', func)

tests/test_jinja_filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def add_2(value):
2222
app,
2323
loader=jinja2.DictLoader({'tmpl.jinja2': "{{ 5|add_2 }}"}),
2424
filters={'add_2': add_2},
25-
enable_async=False,
25+
enable_async=True,
2626
)
2727

2828
app.router.add_route('GET', '/', index)

tests/test_simple_renderer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ def func(request):
242242

243243
client = yield from test_client(app)
244244
resp = yield from client.get('/')
245-
246245
assert 200 == resp.status
247246
txt = yield from resp.text()
248247
assert '<html><body><p></p></body></html>' == txt

0 commit comments

Comments
 (0)