Fix tests (hopefully?)
This commit is contained in:
parent
250c5cf60d
commit
6563ee28bf
@ -4,7 +4,6 @@ import warnings
|
||||
import pytest
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from websockets.version import version as websockets_version
|
||||
|
||||
from sanic import Sanic
|
||||
from sanic.exceptions import (
|
||||
@ -260,15 +259,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
|
||||
|
@ -219,11 +219,13 @@ 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
|
||||
|
@ -40,7 +40,7 @@ def test_no_exceptions_when_cancel_pending_request(app, caplog):
|
||||
|
||||
assert counter[logging.INFO] == 5
|
||||
assert logging.ERROR not in counter
|
||||
assert (
|
||||
caplog.record_tuples[3][2]
|
||||
== "Request: GET http://127.0.0.1:8000/ stopped. Transport is closed."
|
||||
assert any(
|
||||
r[2] == "Request: GET http://127.0.0.1:8000/ stopped. Transport is closed."
|
||||
for r in caplog.record_tuples
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user