Browse Source

Add `pragma: no cover` in some tests

pull/14569/head
Yurii Motov 7 months ago
parent
commit
0c183ee8fc
  1. 2
      tests/test_tutorial/test_debugging/test_tutorial001.py
  2. 4
      tests/test_tutorial/test_query_params_str_validations/test_tutorial006c.py
  3. 2
      tests/test_tutorial/test_settings/test_app01.py

2
tests/test_tutorial/test_debugging/test_tutorial001.py

@ -18,7 +18,7 @@ def get_client():
def test_uvicorn_run_is_not_called_on_import():
if sys.modules.get(MOD_NAME):
del sys.modules[MOD_NAME]
del sys.modules[MOD_NAME] # pragma: no cover
with unittest.mock.patch("uvicorn.run") as uvicorn_run_mock:
importlib.import_module(MOD_NAME)
uvicorn_run_mock.assert_not_called()

4
tests/test_tutorial/test_query_params_str_validations/test_tutorial006c.py

@ -31,7 +31,7 @@ def get_client(request: pytest.FixtureRequest):
def test_query_params_str_validations_no_query(client: TestClient):
response = client.get("/items/")
assert response.status_code == 200
assert response.json() == {
assert response.json() == { # pragma: no cover
"items": [{"item_id": "Foo"}, {"item_id": "Bar"}],
}
@ -42,7 +42,7 @@ def test_query_params_str_validations_no_query(client: TestClient):
def test_query_params_str_validations_empty_str(client: TestClient):
response = client.get("/items/?q=")
assert response.status_code == 200
assert response.json() == {
assert response.json() == { # pragma: no cover
"items": [{"item_id": "Foo"}, {"item_id": "Bar"}],
}

2
tests/test_tutorial/test_settings/test_app01.py

@ -34,7 +34,7 @@ def get_test_client(mod_name: str, monkeypatch: MonkeyPatch) -> TestClient:
def test_settings_validation_error(mod_name: str, monkeypatch: MonkeyPatch):
monkeypatch.delenv("ADMIN_EMAIL", raising=False)
if mod_name in sys.modules:
del sys.modules[mod_name]
del sys.modules[mod_name] # pragma: no cover
with pytest.raises(ValidationError) as exc_info:
importlib.import_module(mod_name)

Loading…
Cancel
Save