Fixed some test errors
This commit is contained in:
parent
12ecf52878
commit
2a35578e46
@ -271,9 +271,13 @@ def test_exception_in_ws_logged(caplog):
|
||||
with caplog.at_level(logging.INFO):
|
||||
app.test_client.websocket("/feed")
|
||||
|
||||
error_logs = [r for r in caplog.record_tuples if r[0] == "sanic.error"]
|
||||
assert error_logs[1][1] == logging.ERROR
|
||||
assert "Exception occurred while handling uri:" in error_logs[1][2]
|
||||
for record in caplog.record_tuples:
|
||||
if record[2].startswith("Exception occurred"):
|
||||
break
|
||||
|
||||
assert record[0] == "sanic.error"
|
||||
assert record[1] == logging.ERROR
|
||||
assert "Exception occurred while handling uri:" in record[2]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("debug", (True, False))
|
||||
|
@ -222,7 +222,7 @@ def test_single_arg_exception_handler_notice(exception_handler_app, caplog):
|
||||
_, response = exception_handler_app.test_client.get("/1")
|
||||
|
||||
for record in caplog.records:
|
||||
if record.message.startswith("You are"):
|
||||
if record.message.startswith("You are using"):
|
||||
break
|
||||
|
||||
assert record.message == (
|
||||
|
@ -2,7 +2,6 @@ import asyncio
|
||||
import logging
|
||||
import time
|
||||
|
||||
from collections import Counter
|
||||
from multiprocessing import Process
|
||||
|
||||
import httpx
|
||||
@ -36,11 +35,14 @@ def test_no_exceptions_when_cancel_pending_request(app, caplog):
|
||||
|
||||
p.kill()
|
||||
|
||||
counter = Counter([r[1] for r in caplog.record_tuples])
|
||||
|
||||
assert counter[logging.INFO] == 11
|
||||
assert logging.ERROR not in counter
|
||||
assert (
|
||||
caplog.record_tuples[9][2]
|
||||
== "Request: GET http://127.0.0.1:8000/ stopped. Transport is closed."
|
||||
)
|
||||
info = 0
|
||||
for record in caplog.record_tuples:
|
||||
assert record[1] != logging.ERROR
|
||||
if record[1] == logging.INFO:
|
||||
info += 1
|
||||
if record[2].startswith("Request:"):
|
||||
assert record[2] == (
|
||||
"Request: GET http://127.0.0.1:8000/ stopped. "
|
||||
"Transport is closed."
|
||||
)
|
||||
assert info == 11
|
||||
|
Loading…
x
Reference in New Issue
Block a user