Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for client on test_connection_lost_before_handshake_complete #2001

Merged
merged 17 commits into from
Jun 10, 2023
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [ -z $GITHUB_ACTIONS ]; then
scripts/check
fi

${PREFIX}coverage run --debug config -m pytest "$@"
${PREFIX}coverage run --debug config -m pytest "$@" -s
Kludex marked this conversation as resolved.
Show resolved Hide resolved

if [ -z $GITHUB_ACTIONS ]; then
scripts/coverage
Expand Down
4 changes: 3 additions & 1 deletion tests/protocols/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ async def app(scope, receive, send):
async def websocket_session(uri):
nonlocal response
async with httpx.AsyncClient() as client:
print("2.5")
Kludex marked this conversation as resolved.
Show resolved Hide resolved
response = await client.get(
f"http://127.0.0.1:{unused_tcp_port}",
headers={
Expand All @@ -749,12 +750,13 @@ async def websocket_session(uri):
)
await asyncio.sleep(0.1)
send_accept_task.set()
await asyncio.sleep(0.1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this tick was needed 😄


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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_auto_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion uvicorn/middleware/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]