]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
tests: branches coverage in `test_authentication`, `test_background`, `test_responses...
authorRenan Heckert Leal <123672970+lealre@users.noreply.github.com>
Sun, 15 Dec 2024 15:28:16 +0000 (15:28 +0000)
committerGitHub <noreply@github.com>
Sun, 15 Dec 2024 15:28:16 +0000 (15:28 +0000)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
tests/test_authentication.py
tests/test_background.py
tests/test_responses.py
tests/test_routing.py

index 3c013a3a721579e474f4d6bd393e5e2c8b4a26fa..40886cd236351e95757ffda32d6aea8e8c0fdcb9 100644 (file)
@@ -210,8 +210,8 @@ def test_invalid_decorator_usage() -> None:
     with pytest.raises(Exception):
 
         @requires("authenticated")
-        def foo() -> None:
-            pass  # pragma: no cover
+        def foo() -> None:  # pragma: no cover
+            pass
 
 
 def test_user_interface(test_client_factory: TestClientFactory) -> None:
index 990e270ea678bc59fa0f9b27f89eb3aeb2d756b5..48f348769e8564cdcf7466009332788b31711370 100644 (file)
@@ -73,7 +73,7 @@ def test_multi_tasks_failure_avoids_next_execution(
     def increment() -> None:
         nonlocal TASK_COUNTER
         TASK_COUNTER += 1
-        if TASK_COUNTER == 1:
+        if TASK_COUNTER == 1:  # pragma: no branch
             raise Exception("task failed")
 
     async def app(scope: Scope, receive: Receive, send: Send) -> None:
index f22b43b0195a41552e8ef084881d4f3f63d7ff65..3c2d346d35de05250cc326b0e45a71ad8c7d89b7 100644 (file)
@@ -265,7 +265,7 @@ async def test_file_response_on_head_method(tmp_path: Path) -> None:
             assert "content-disposition" in headers
             assert "last-modified" in headers
             assert "etag" in headers
-        elif message["type"] == "http.response.body":
+        elif message["type"] == "http.response.body":  # pragma: no branch
             assert message["body"] == b""
             assert message["more_body"] is False
 
@@ -749,7 +749,7 @@ async def test_file_response_multi_small_chunk_size(readme_file: Path) -> None:
     async def send(message: Message) -> None:
         if message["type"] == "http.response.start":
             start_message.update(message)
-        elif message["type"] == "http.response.body":
+        elif message["type"] == "http.response.body":  # pragma: no branch
             received_chunks.append(message["body"])
 
     await app({"type": "http", "method": "get", "headers": [(b"range", b"bytes=0-15,20-35,35-50")]}, receive, send)
index 6abdc564c138a5f2591a8755bc094ecf3b546c50..b1322544aaaa76d27d829dc9581c2ba233014f00 100644 (file)
@@ -797,7 +797,7 @@ def test_raise_on_startup(test_client_factory: TestClientFactory) -> None:
     async def app(scope: Scope, receive: Receive, send: Send) -> None:
         async def _send(message: Message) -> None:
             nonlocal startup_failed
-            if message["type"] == "lifespan.startup.failed":
+            if message["type"] == "lifespan.startup.failed":  # pragma: no branch
                 startup_failed = True
             return await send(message)