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

tests: adding # pragma: no branch in middleware/test_base and test_routing #2807

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tests/middleware/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async def receive() -> Message:

async def send(message: Message) -> None:
if message["type"] == "http.response.body":
if not message.get("more_body", False):
if not message.get("more_body", False): # pragma: no branch
response_complete.set()

await app(scope, receive, send)
Expand Down Expand Up @@ -402,7 +402,7 @@ async def receive() -> Message:

async def send(message: Message) -> None:
if message["type"] == "http.response.body":
if not message.get("more_body", False):
if not message.get("more_body", False): # pragma: no branch
response_complete.set()

await app(scope, receive, send)
Expand Down Expand Up @@ -456,7 +456,7 @@ async def cancel_on_disconnect(
task_status.started()
while True:
message = await receive()
if message["type"] == "http.disconnect":
if message["type"] == "http.disconnect": # pragma: no branch
task_group.cancel_scope.cancel()
break

Expand Down Expand Up @@ -717,7 +717,7 @@ async def dispatch(
async def test_read_request_stream_in_dispatch_wrapping_app_calls_body() -> None:
async def endpoint(scope: Scope, receive: Receive, send: Send) -> None:
request = Request(scope, receive)
async for chunk in request.stream():
async for chunk in request.stream(): # pragma: no branch
assert chunk == b"2"
break
await Response()(scope, receive, send)
Expand All @@ -730,7 +730,7 @@ async def dispatch(
) -> Response:
expected = b"1"
response: Response | None = None
async for chunk in request.stream():
async for chunk in request.stream(): # pragma: no branch
assert chunk == expected
if expected == b"1":
response = await call_next(request)
Expand Down Expand Up @@ -943,7 +943,7 @@ def modifying_middleware(app: ASGIApp) -> ASGIApp:
async def wrapped_app(scope: Scope, receive: Receive, send: Send) -> None:
async def wrapped_receive() -> Message:
msg = await receive()
if msg["type"] == "http.request":
if msg["type"] == "http.request": # pragma: no branch
msg["body"] = msg["body"] * 2
return msg

Expand Down
2 changes: 1 addition & 1 deletion tests/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ def __call__(self, request: Request) -> None: ... # pragma: no cover
id="staticmethod",
),
pytest.param(Endpoint(), "Endpoint", id="object"),
pytest.param(lambda request: ..., "<lambda>", id="lambda"),
pytest.param(lambda request: ..., "<lambda>", id="lambda"), # pragma: no branch
],
)
def test_route_name(endpoint: typing.Callable[..., Response], expected_name: str) -> None:
Expand Down
Loading