Fixing typing for ListenerMixin.listener (#2376)

Co-authored-by: Adam Hopkins <adam@amhopkins.com>
This commit is contained in:
André Ericson
2022-03-23 14:34:33 +01:00
committed by GitHub
parent 6e0a6871b5
commit 32962d1e1c
3 changed files with 49 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import pytest
from sanic_testing.testing import HOST, PORT
from sanic.compat import ctrlc_workaround_for_windows
from sanic.exceptions import InvalidUsage
from sanic.response import HTTPResponse
@@ -108,3 +109,17 @@ def test_windows_workaround():
assert res == "OK"
res = loop.run_until_complete(atest(True))
assert res == "OK"
@pytest.mark.skipif(os.name == "nt", reason="May hang CI on py38/windows")
def test_signals_with_invalid_invocation(app):
"""Test if sanic register fails with invalid invocation"""
@app.route("/hello")
async def hello_route(request):
return HTTPResponse()
with pytest.raises(
InvalidUsage, match="Invalid event registration: Missing event name"
):
app.listener(stop)