]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
tests: adding `# pragma: no branch` in `middleware/test_base` and `test_routing`...
authorRenan Heckert Leal <123672970+lealre@users.noreply.github.com>
Sat, 21 Dec 2024 19:11:28 +0000 (19:11 +0000)
committerGitHub <noreply@github.com>
Sat, 21 Dec 2024 19:11:28 +0000 (19:11 +0000)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
tests/middleware/test_base.py
tests/test_routing.py

index fa0cba47929f8a4a74ca98baae5189adb650c752..449624e2f138488bcdadbdd551c06a34d5a673fa 100644 (file)
@@ -288,7 +288,7 @@ async def test_run_background_tasks_even_if_client_disconnects() -> None:
 
     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 test_run_context_manager_exit_even_if_client_disconnects() -> None:
 
     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 @@ def test_app_receives_http_disconnect_while_sending_if_discarded(
                 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 @@ def test_read_request_stream_in_dispatch_after_app_calls_body(
 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 test_read_request_stream_in_dispatch_wrapping_app_calls_body() -> None
         ) -> 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 test_downstream_middleware_modifies_receive(
         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
 
index b1322544aaaa76d27d829dc9581c2ba233014f00..6d7e5d1545261c8335fa7da7d61431d3945c36ad 100644 (file)
@@ -883,7 +883,7 @@ class Endpoint:
             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: