Skip to content

Commit

Permalink
Add an xfailing test expecting HTTP500 for invalid handler return values
Browse files Browse the repository at this point in the history
PR #4574 by @Fogapod

This change documents a contract of disallowing non-response
return values in request handlers that currently has a bug and
is therefore marked as xfail.

Ref: #4572
  • Loading branch information
Fogapod authored Feb 14, 2020
1 parent f80029b commit 1740c99
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from yarl import URL

from aiohttp import HttpVersion, web
from aiohttp.client_exceptions import ServerDisconnectedError
from aiohttp.helpers import DEBUG
from aiohttp.http_parser import RawRequestMessage
from aiohttp.streams import StreamReader
Expand Down Expand Up @@ -771,3 +772,19 @@ async def handler(request):
def test_weakref_creation() -> None:
req = make_mocked_request('GET', '/')
weakref.ref(req)


@pytest.mark.xfail(
raises=ServerDisconnectedError,
reason="see https://github.com/aio-libs/aiohttp/issues/4572"
)
async def test_handler_return_type(aiohttp_client) -> None:
async def invalid_handler_1(request):
return 1

app = web.Application()
app.router.add_get('/1', invalid_handler_1)
client = await aiohttp_client(app)

async with client.get('/1') as resp:
assert 500 == resp.status

0 comments on commit 1740c99

Please sign in to comment.