Skip to content

Commit

Permalink
tests: branches coverage in test_authentication, test_background,…
Browse files Browse the repository at this point in the history
… `test_responses`, `test_routing`
  • Loading branch information
lealre committed Dec 14, 2024
1 parent 672cd42 commit afeed0d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -871,7 +871,7 @@ async def my_staticmethod(request: Request) -> None: ... # pragma: no cover
def __call__(self, request: Request) -> None: ... # pragma: no cover


@pytest.mark.parametrize(
@pytest.mark.parametrize( # pragma: no branch
"endpoint, expected_name",
[
pytest.param(func_homepage, "func_homepage", id="function"),
Expand Down

0 comments on commit afeed0d

Please sign in to comment.