Fix some tests
This commit is contained in:
parent
e6a195b61f
commit
5ca22d7a40
@ -260,15 +260,10 @@ def test_exception_in_ws_logged(caplog):
|
|||||||
raise Exception("...")
|
raise Exception("...")
|
||||||
|
|
||||||
with caplog.at_level(logging.INFO):
|
with caplog.at_level(logging.INFO):
|
||||||
app.test_client.websocket("/feed")
|
req, _ = app.test_client.websocket("/feed")
|
||||||
# Websockets v10.0 and above output an additional
|
|
||||||
# INFO message when a ws connection is accepted
|
|
||||||
ws_version_parts = websockets_version.split(".")
|
|
||||||
ws_major = int(ws_version_parts[0])
|
|
||||||
record_index = 2 if ws_major >= 10 else 1
|
|
||||||
assert caplog.record_tuples[record_index][0] == "sanic.error"
|
|
||||||
assert caplog.record_tuples[record_index][1] == logging.ERROR
|
|
||||||
assert (
|
assert (
|
||||||
"Exception occurred while handling uri:"
|
"sanic.error",
|
||||||
in caplog.record_tuples[record_index][2]
|
logging.ERROR,
|
||||||
)
|
"Exception occurred while handling uri: %s" % repr(req.url),
|
||||||
|
) in caplog.record_tuples
|
||||||
|
@ -220,13 +220,15 @@ def test_single_arg_exception_handler_notice(exception_handler_app, caplog):
|
|||||||
with caplog.at_level(logging.WARNING):
|
with caplog.at_level(logging.WARNING):
|
||||||
_, response = exception_handler_app.test_client.get("/1")
|
_, response = exception_handler_app.test_client.get("/1")
|
||||||
|
|
||||||
assert caplog.records[0].message == (
|
assert (
|
||||||
|
"sanic.error",
|
||||||
|
logging.WARNING,
|
||||||
"You are using a deprecated error handler. The lookup method should "
|
"You are using a deprecated error handler. The lookup method should "
|
||||||
"accept two positional parameters: (exception, route_name: "
|
"accept two positional parameters: (exception, route_name: "
|
||||||
"Optional[str]). Until you upgrade your ErrorHandler.lookup, "
|
"Optional[str]). Until you upgrade your ErrorHandler.lookup, "
|
||||||
"Blueprint specific exceptions will not work properly. Beginning in "
|
"Blueprint specific exceptions will not work properly. Beginning in "
|
||||||
"v22.3, the legacy style lookup method will not work at all."
|
"v22.3, the legacy style lookup method will not work at all."
|
||||||
)
|
) in caplog.record_tuples
|
||||||
assert response.status == 400
|
assert response.status == 400
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user