diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 503e47cb..71d3c2c8 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -260,15 +260,10 @@ def test_exception_in_ws_logged(caplog): raise Exception("...") with caplog.at_level(logging.INFO): - 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 + req, _ = app.test_client.websocket("/feed") + assert ( - "Exception occurred while handling uri:" - in caplog.record_tuples[record_index][2] - ) + "sanic.error", + logging.ERROR, + "Exception occurred while handling uri: %s" % repr(req.url), + ) in caplog.record_tuples diff --git a/tests/test_exceptions_handler.py b/tests/test_exceptions_handler.py index edc5a327..a953c4f2 100644 --- a/tests/test_exceptions_handler.py +++ b/tests/test_exceptions_handler.py @@ -220,13 +220,15 @@ def test_single_arg_exception_handler_notice(exception_handler_app, caplog): with caplog.at_level(logging.WARNING): _, 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 " "accept two positional parameters: (exception, route_name: " "Optional[str]). Until you upgrade your ErrorHandler.lookup, " "Blueprint specific exceptions will not work properly. Beginning in " "v22.3, the legacy style lookup method will not work at all." - ) + ) in caplog.record_tuples assert response.status == 400