Skip to content

Commit

Permalink
fix reason parameter in HTTPInternalServerError (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
jettify authored and asvetlov committed Sep 26, 2016
1 parent 6012a11 commit 1ead771
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions aiohttp_jinja2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def render_string(template_name, request, context, *, app_key=APP_KEY):
try:
template = env.get_template(template_name)
except jinja2.TemplateNotFound as e:
raise web.HTTPInternalServerError(
text="Template '{}' not found".format(template_name)) from e
text = "Template '{}' not found".format(template_name)
raise web.HTTPInternalServerError(reason=text, text=text) from e
if not isinstance(context, Mapping):
text = "context should be mapping, not {}".format(type(context))
# same reason as above
Expand Down
5 changes: 3 additions & 2 deletions tests/test_simple_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ def go():
with self.assertRaises(web.HTTPInternalServerError) as ctx:
yield from func(req)

self.assertEqual("Template 'template' not found",
ctx.exception.text)
t = "Template 'template' not found"
self.assertEqual(t, ctx.exception.text)
self.assertEqual(t, ctx.exception.reason)

self.loop.run_until_complete(go())

Expand Down

0 comments on commit 1ead771

Please sign in to comment.