From f884b6649ea7e0b019443a265db7ff62ebe7914b Mon Sep 17 00:00:00 2001 From: Renan Heckert Leal <123672970+lealre@users.noreply.github.com> Date: Sat, 21 Dec 2024 19:11:28 +0000 Subject: [PATCH] tests: adding `# pragma: no branch` in `middleware/test_base` and `test_routing` (#2807) Co-authored-by: Marcelo Trylesinski --- tests/middleware/test_base.py | 12 ++++++------ tests/test_routing.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/middleware/test_base.py b/tests/middleware/test_base.py index fa0cba479..449624e2f 100644 --- a/tests/middleware/test_base.py +++ b/tests/middleware/test_base.py @@ -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) @@ -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) @@ -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 @@ -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) @@ -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) @@ -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 diff --git a/tests/test_routing.py b/tests/test_routing.py index b1322544a..6d7e5d154 100644 --- a/tests/test_routing.py +++ b/tests/test_routing.py @@ -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: ..., "", id="lambda"), + pytest.param(lambda request: ..., "", id="lambda"), # pragma: no branch ], ) def test_route_name(endpoint: typing.Callable[..., Response], expected_name: str) -> None: