Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: branches coverage in test_authentication, test_background, test_responses, test_routing #2796

Merged
merged 4 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Kludex marked this conversation as resolved.
Show resolved Hide resolved
"endpoint, expected_name",
[
pytest.param(func_homepage, "func_homepage", id="function"),
Expand Down
Loading