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):
|
with caplog.at_level(logging.INFO):
|
||||||
app.test_client.websocket("/feed")
|
app.test_client.websocket("/feed")
|
||||||
|
|
||||||
error_logs = [r for r in caplog.record_tuples if r[0] == "sanic.error"]
|
for record in caplog.record_tuples:
|
||||||
assert error_logs[1][1] == logging.ERROR
|
if record[2].startswith("Exception occurred"):
|
||||||
assert "Exception occurred while handling uri:" in error_logs[1][2]
|
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))
|
@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")
|
_, response = exception_handler_app.test_client.get("/1")
|
||||||
|
|
||||||
for record in caplog.records:
|
for record in caplog.records:
|
||||||
if record.message.startswith("You are"):
|
if record.message.startswith("You are using"):
|
||||||
break
|
break
|
||||||
|
|
||||||
assert record.message == (
|
assert record.message == (
|
||||||
|
@ -2,7 +2,6 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from collections import Counter
|
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
@ -36,11 +35,14 @@ def test_no_exceptions_when_cancel_pending_request(app, caplog):
|
|||||||
|
|
||||||
p.kill()
|
p.kill()
|
||||||
|
|
||||||
counter = Counter([r[1] for r in caplog.record_tuples])
|
info = 0
|
||||||
|
for record in caplog.record_tuples:
|
||||||
assert counter[logging.INFO] == 11
|
assert record[1] != logging.ERROR
|
||||||
assert logging.ERROR not in counter
|
if record[1] == logging.INFO:
|
||||||
assert (
|
info += 1
|
||||||
caplog.record_tuples[9][2]
|
if record[2].startswith("Request:"):
|
||||||
== "Request: GET http://127.0.0.1:8000/ stopped. Transport is closed."
|
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