From 7fed2671c4c8e3651911df05d36b4a93d3a4f294 Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Thu, 5 Feb 2026 15:38:23 +0100 Subject: [PATCH] Add `pragma: no cover` to make coverage pass --- .../test_body/test_nullable_and_defaults.py | 15 ++++++++------ .../test_cookie/test_nullable_and_defaults.py | 5 +++-- .../test_file/test_nullable_and_defaults.py | 7 ++++--- .../test_form/test_nullable_and_defaults.py | 20 +++++++++++-------- .../test_header/test_nullable_and_defaults.py | 5 +++-- .../test_query/test_nullable_and_defaults.py | 6 ++++-- 6 files changed, 35 insertions(+), 23 deletions(-) diff --git a/tests/test_request_params/test_body/test_nullable_and_defaults.py b/tests/test_request_params/test_body/test_nullable_and_defaults.py index 3f0afd5cad..13d2df4796 100644 --- a/tests/test_request_params/test_body/test_nullable_and_defaults.py +++ b/tests/test_request_params/test_body/test_nullable_and_defaults.py @@ -332,8 +332,9 @@ def test_nullable_required_no_embed_pass_null(path: str): response = client.post(path, content="null") assert mock_convert.call_count == 1, "Validator should be called once for the field" - assert response.status_code == 200, response.text - assert response.json() == {"val": None} + assert response.status_code == 200, response.text # pragma: no cover + assert response.json() == {"val": None} # pragma: no cover + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( @@ -672,8 +673,9 @@ def test_nullable_non_required_no_embed_pass_null(path: str): response = client.post(path, content="null") assert mock_convert.call_count == 1, "Validator should be called once for the field" - assert response.status_code == 200, response.text - assert response.json() == {"val": None} + assert response.status_code == 200, response.text # pragma: no cover + assert response.json() == {"val": None} # pragma: no cover + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( @@ -1019,8 +1021,9 @@ def test_nullable_with_non_null_default_no_embed_pass_null(path: str): response = client.post(path, content="null") assert mock_convert.call_count == 1, "Validator should be called once for the field" - assert response.status_code == 200, response.text - assert response.json() == {"val": None} + assert response.status_code == 200, response.text # pragma: no cover + assert response.json() == {"val": None} # pragma: no cover + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( diff --git a/tests/test_request_params/test_cookie/test_nullable_and_defaults.py b/tests/test_request_params/test_cookie/test_nullable_and_defaults.py index 468d167af0..88fa4f78d3 100644 --- a/tests/test_request_params/test_cookie/test_nullable_and_defaults.py +++ b/tests/test_request_params/test_cookie/test_nullable_and_defaults.py @@ -369,12 +369,13 @@ def test_nullable_with_non_null_default_missing(path: str): assert mock_convert.call_count == 0, ( "Validator should not be called if the value is missing" ) - assert response.status_code == 200 - assert response.json() == { + assert response.status_code == 200 # pragma: no cover + assert response.json() == { # pragma: no cover "int_val": -1, "str_val": "default", "fields_set": IsOneOf(None, []), } + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( diff --git a/tests/test_request_params/test_file/test_nullable_and_defaults.py b/tests/test_request_params/test_file/test_nullable_and_defaults.py index ce862dc465..4c34889e52 100644 --- a/tests/test_request_params/test_file/test_nullable_and_defaults.py +++ b/tests/test_request_params/test_file/test_nullable_and_defaults.py @@ -417,11 +417,12 @@ def test_nullable_with_non_null_default_missing(path: str): with patch(f"{__name__}.convert", Mock(wraps=convert)) as mock_convert: response = client.post(path) - assert mock_convert.call_count == 0, ( + assert mock_convert.call_count == 0, ( # pragma: no cover "Validator should not be called if the value is missing" ) - assert response.status_code == 200 - assert response.json() == {"file": None, "files": None} + assert response.status_code == 200 # pragma: no cover + assert response.json() == {"file": None, "files": None} # pragma: no cover + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( diff --git a/tests/test_request_params/test_form/test_nullable_and_defaults.py b/tests/test_request_params/test_form/test_nullable_and_defaults.py index 6b9ac4c300..d8147ca790 100644 --- a/tests/test_request_params/test_form/test_nullable_and_defaults.py +++ b/tests/test_request_params/test_form/test_nullable_and_defaults.py @@ -180,8 +180,8 @@ def test_nullable_required_pass_empty_str(path: str): (""), # str_val (["0"]), # list_val ] - assert response.status_code == 200, response.text - assert response.json() == { + assert response.status_code == 200, response.text # pragma: no cover + assert response.json() == { # pragma: no cover "int_val": None, "str_val": None, "list_val": [0], @@ -189,6 +189,7 @@ def test_nullable_required_pass_empty_str(path: str): None, IsList("int_val", "str_val", "list_val", check_order=False) ), } + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( @@ -368,8 +369,8 @@ def test_nullable_non_required_pass_empty_str(path: str): (""), # str_val (["0"]), # list_val ] - assert response.status_code == 200, response.text - assert response.json() == { + assert response.status_code == 200, response.text # pragma: no cover + assert response.json() == { # pragma: no cover "int_val": None, "str_val": None, "list_val": [0], @@ -377,6 +378,7 @@ def test_nullable_non_required_pass_empty_str(path: str): None, IsList("int_val", "str_val", "list_val", check_order=False) ), } + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( @@ -522,13 +524,14 @@ def test_nullable_with_non_null_default_missing(path: str): assert mock_convert.call_count == 0, ( "Validator should not be called if the value is missing" ) - assert response.status_code == 200 - assert response.json() == { + assert response.status_code == 200 # pragma: no cover + assert response.json() == { # pragma: no cover "int_val": -1, "str_val": "default", "list_val": [0], "fields_set": IsOneOf(None, []), } + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( @@ -567,8 +570,8 @@ def test_nullable_with_non_null_default_pass_empty_str(path: str): (""), # str_val (["0"]), # list_val ] - assert response.status_code == 200, response.text - assert response.json() == { + assert response.status_code == 200, response.text # pragma: no cover + assert response.json() == { # pragma: no cover "int_val": None, "str_val": None, "list_val": [0], @@ -576,6 +579,7 @@ def test_nullable_with_non_null_default_pass_empty_str(path: str): None, IsList("int_val", "str_val", "list_val", check_order=False) ), } + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( diff --git a/tests/test_request_params/test_header/test_nullable_and_defaults.py b/tests/test_request_params/test_header/test_nullable_and_defaults.py index 6cb555f374..5aaae8592a 100644 --- a/tests/test_request_params/test_header/test_nullable_and_defaults.py +++ b/tests/test_request_params/test_header/test_nullable_and_defaults.py @@ -483,13 +483,14 @@ def test_nullable_with_non_null_default_missing(path: str): assert mock_convert.call_count == 0, ( "Validator should not be called if the value is missing" ) - assert response.status_code == 200 - assert response.json() == { + assert response.status_code == 200 # pragma: no cover + assert response.json() == { # pragma: no cover "int_val": -1, "str_val": "default", "list_val": [0], "fields_set": IsOneOf(None, []), } + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize( diff --git a/tests/test_request_params/test_query/test_nullable_and_defaults.py b/tests/test_request_params/test_query/test_nullable_and_defaults.py index f329e08886..e72bc2d629 100644 --- a/tests/test_request_params/test_query/test_nullable_and_defaults.py +++ b/tests/test_request_params/test_query/test_nullable_and_defaults.py @@ -426,6 +426,7 @@ def test_nullable_with_non_null_default_schema(path: str): # default_factory is not reflected in OpenAPI schema assert parameters[2]["schema"]["default"] == [0] + @pytest.mark.parametrize( "path", [ @@ -445,13 +446,14 @@ def test_nullable_with_non_null_default_missing(path: str): assert mock_convert.call_count == 0, ( "Validator should not be called if the value is missing" ) - assert response.status_code == 200 - assert response.json() == { + assert response.status_code == 200 # pragma: no cover + assert response.json() == { # pragma: no cover "int_val": -1, "str_val": "default", "list_val": [0], "fields_set": IsOneOf(None, []), } + # TODO: Remove 'no cover' when the issue is fixed @pytest.mark.parametrize(