From 827de43b97ad58c7b8daae12ad17c1848a4f1341 Mon Sep 17 00:00:00 2001 From: Renan Heckert Leal <123672970+lealre@users.noreply.github.com> Date: Sun, 15 Dec 2024 15:28:16 +0000 Subject: [PATCH] tests: branches coverage in `test_authentication`, `test_background`, `test_responses`, `test_routing` (#2796) Co-authored-by: Marcelo Trylesinski --- tests/test_authentication.py | 4 ++-- tests/test_background.py | 2 +- tests/test_responses.py | 4 ++-- tests/test_routing.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_authentication.py b/tests/test_authentication.py index 3c013a3a7..40886cd23 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -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: diff --git a/tests/test_background.py b/tests/test_background.py index 990e270ea..48f348769 100644 --- a/tests/test_background.py +++ b/tests/test_background.py @@ -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: diff --git a/tests/test_responses.py b/tests/test_responses.py index f22b43b01..3c2d346d3 100644 --- a/tests/test_responses.py +++ b/tests/test_responses.py @@ -265,7 +265,7 @@ async def send(message: Message) -> 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 receive() -> Message: 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) diff --git a/tests/test_routing.py b/tests/test_routing.py index 6abdc564c..b1322544a 100644 --- a/tests/test_routing.py +++ b/tests/test_routing.py @@ -797,7 +797,7 @@ def run_startup() -> 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)