Skip to content

Commit 8dce3f4

Browse files
committed
Check coverage of (most) tests.
The end-to-end tests and their associated fixtures are deliberately not included in normal test runs, so they also aren't included in coverage reporting.
1 parent 1254d13 commit 8dce3f4

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

noxfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def tests_with_coverage(session: nox.Session) -> None:
8080
"run",
8181
"--source",
8282
PACKAGE_NAME,
83+
"--source",
84+
"tests/",
8385
"-m",
8486
"pytest",
8587
"-m",

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ target-version = ["py39", "py310", "py311", "py312", "py313"]
5858
source = ["src", ".nox/tests_with_coverage*/**/site-packages"]
5959

6060
[tool.coverage.report]
61+
omit = [
62+
"tests/conftest.py",
63+
"tests/end_to_end/*"
64+
]
6165
fail_under = 100
6266

6367
[tool.coverage.run]

tests/test_legacy_client.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# SPDX-License-Identifier: BSD-3-Clause
1212

1313
import os
14-
import typing
1514
import unittest
1615
from http import HTTPStatus
1716

@@ -25,7 +24,6 @@
2524
def _make_fixed_response_transport(
2625
response_text: str = "true",
2726
status_code: HTTPStatus = HTTPStatus.OK,
28-
response_json: typing.Optional[dict] = None,
2927
) -> httpx.MockTransport:
3028
"""
3129
Return an ``httpx`` transport that produces a fixed response, for use
@@ -34,7 +32,6 @@ def _make_fixed_response_transport(
3432
The transport will return a response consisting of:
3533
3634
* ``status_code`` (default 200)
37-
* ``response_json`` as the JSON content, if supplied
3835
* Otherwise ``response_text`` (default ``"true"``) as the response text
3936
4037
"""
@@ -46,29 +43,22 @@ def _handler(
4643
Mock transport handler which returns a controlled response.
4744
4845
"""
49-
response_kwargs = {"status_code": status_code, "content": response_text}
50-
if response_json is not None:
51-
del response_kwargs["content"]
52-
response_kwargs["json"] = response_json
53-
return httpx.Response(**response_kwargs) # type: ignore
46+
return httpx.Response(status_code=status_code, content=response_text)
5447

5548
return httpx.MockTransport(_handler)
5649

5750

5851
def _make_fixed_response_sync_client(
5952
response_text: str = "true",
6053
status_code: HTTPStatus = HTTPStatus.OK,
61-
response_json: typing.Optional[dict] = None,
6254
) -> httpx.Client:
6355
"""
6456
Return a synchronous HTTP client that produces a fixed repsonse, for use in
6557
testing.
6658
6759
"""
6860
return httpx.Client(
69-
transport=_make_fixed_response_transport(
70-
response_text, status_code, response_json
71-
)
61+
transport=_make_fixed_response_transport(response_text, status_code)
7262
)
7363

7464

0 commit comments

Comments
 (0)