Run strict mypy on test suite (#2771)
This commit is contained in:
parent
4f40b84957
commit
865ce7c0b4
@ -113,15 +113,10 @@ combine-as-imports = true
|
||||
warn_unused_ignores = true
|
||||
warn_redundant_casts = true
|
||||
show_error_codes = true
|
||||
disallow_untyped_defs = true
|
||||
disallow_untyped_defs = false
|
||||
ignore_missing_imports = true
|
||||
follow_imports = "silent"
|
||||
|
||||
[[tool.mypy.overrides]]
|
||||
module = "tests.*"
|
||||
disallow_untyped_defs = false
|
||||
check_untyped_defs = true
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "-rxXs --strict-config --strict-markers -n 8"
|
||||
xfail_strict = true
|
||||
|
||||
@ -2,13 +2,14 @@ import httpx
|
||||
import pytest
|
||||
|
||||
from tests.middleware.test_logging import caplog_for_logger
|
||||
from uvicorn._types import ASGIReceiveCallable, ASGISendCallable, Scope
|
||||
from uvicorn.logging import TRACE_LOG_LEVEL
|
||||
from uvicorn.middleware.message_logger import MessageLoggerMiddleware
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_message_logger(caplog):
|
||||
async def app(scope, receive, send):
|
||||
async def test_message_logger(caplog: pytest.LogCaptureFixture) -> None:
|
||||
async def app(scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None:
|
||||
await receive()
|
||||
await send({"type": "http.response.start", "status": 200, "headers": []})
|
||||
await send({"type": "http.response.body", "body": b"", "more_body": False})
|
||||
@ -30,8 +31,8 @@ async def test_message_logger(caplog):
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_message_logger_exc(caplog):
|
||||
async def app(scope, receive, send):
|
||||
async def test_message_logger_exc(caplog: pytest.LogCaptureFixture) -> None:
|
||||
async def app(scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None:
|
||||
raise RuntimeError()
|
||||
|
||||
with caplog_for_logger(caplog, "uvicorn.asgi"):
|
||||
|
||||
@ -29,12 +29,8 @@ def new_console_in_windows(test_function: Callable[[], Any]) -> Callable[[], Any
|
||||
name = test_function.__name__
|
||||
|
||||
subprocess.check_call(
|
||||
[
|
||||
sys.executable,
|
||||
"-c",
|
||||
f"from {module} import {name}; {name}.__wrapped__()",
|
||||
],
|
||||
creationflags=subprocess.CREATE_NO_WINDOW, # type: ignore[attr-defined]
|
||||
[sys.executable, "-c", f"from {module} import {name}; {name}.__wrapped__()"],
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
)
|
||||
|
||||
return new_function
|
||||
|
||||
@ -44,9 +44,7 @@ def test_loop_auto():
|
||||
async def test_http_auto():
|
||||
config = Config(app=app)
|
||||
server_state = ServerState()
|
||||
protocol = AutoHTTPProtocol( # type: ignore[call-arg]
|
||||
config=config, server_state=server_state, app_state={}
|
||||
)
|
||||
protocol = AutoHTTPProtocol(config=config, server_state=server_state, app_state={})
|
||||
assert type(protocol).__name__ == expected_http
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user