diff --git a/pyproject.toml b/pyproject.toml index bf76ab36b..9f869b036 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,6 +111,9 @@ exclude_lines = [ "raise NotImplementedError", ] +[tool.coverage.coverage_conditional_plugin.omit] +"uvicorn/loops/uvloop.py" = "sys_platform == 'win32'" + [tool.coverage.coverage_conditional_plugin.rules] py-win32 = "sys_platform == 'win32'" py-not-win32 = "sys_platform != 'win32'" diff --git a/tests/protocols/test_websocket.py b/tests/protocols/test_websocket.py index 22afeffad..d6988e8f5 100644 --- a/tests/protocols/test_websocket.py +++ b/tests/protocols/test_websocket.py @@ -749,12 +749,13 @@ async def websocket_session(uri): ) await asyncio.sleep(0.1) send_accept_task.set() + await asyncio.sleep(0.1) - task.cancel() assert response is not None assert response.status_code == 500, response.text assert response.text == "Internal Server Error" assert disconnect_message == {"type": "websocket.disconnect", "code": 1006} + await task @pytest.mark.anyio diff --git a/tests/test_auto_detection.py b/tests/test_auto_detection.py index 3ea452de3..e4d55cbf2 100644 --- a/tests/test_auto_detection.py +++ b/tests/test_auto_detection.py @@ -11,7 +11,7 @@ try: importlib.import_module("uvloop") - expected_loop = "uvloop" + expected_loop = "uvloop" # pragma: py-not-win32 except ImportError: # pragma: no cover expected_loop = "asyncio" diff --git a/uvicorn/middleware/wsgi.py b/uvicorn/middleware/wsgi.py index b87984488..381eca68e 100644 --- a/uvicorn/middleware/wsgi.py +++ b/uvicorn/middleware/wsgi.py @@ -199,5 +199,5 @@ def wsgi(self, environ: Environ, start_response: StartResponse) -> None: try: from a2wsgi import WSGIMiddleware -except ModuleNotFoundError: +except ModuleNotFoundError: # pragma: no cover WSGIMiddleware = _WSGIMiddleware # type: ignore[misc, assignment]