fastapi-azure-auth icon indicating copy to clipboard operation
fastapi-azure-auth copied to clipboard

Missing coverage when targeting `tests` folder

Open davidhuser opened this issue 5 months ago • 1 comments

If we additionally check the coverage of the tests folder itself, we get only 98%:

poetry run pytest --cov fastapi_azure_auth --cov=tests --cov-report=term-missing

---------- coverage: platform darwin, python 3.12.9-final-0 ----------
Name                                                   Stmts   Miss  Cover   Missing
------------------------------------------------------------------------------------
fastapi_azure_auth/__init__.py                             2      0   100%
fastapi_azure_auth/auth.py                               117      0   100%
fastapi_azure_auth/exceptions.py                          41      0   100%
fastapi_azure_auth/openid_config.py                       65      0   100%
fastapi_azure_auth/user.py                                61      0   100%
fastapi_azure_auth/utils.py                               12      0   100%
tests/__init__.py                                          0      0   100%
tests/conftest.py                                          6      0   100%
tests/multi_tenant/__init__.py                             0      0   100%
tests/multi_tenant/conftest.py                            48      0   100%
tests/multi_tenant/multi_auth/__init__.py                  0      0   100%
tests/multi_tenant/multi_auth/test_auto_error.py          30      0   100%
tests/multi_tenant/test_multi_tenant.py                  120      0   100%
tests/multi_tenant/test_settings.py                        8      1    88%   7
tests/multi_tenant/test_websocket.py                     166     22    87%   36, 48-50, 57-59, 76, 93, 121, 130, 141, 152, 165, 176, 187, 197, 207, 223, 234, 245, 256
tests/multi_tenant_b2c/__init__.py                         0      0   100%
tests/multi_tenant_b2c/conftest.py                        43      1    98%   68
tests/multi_tenant_b2c/multi_auth/__init__.py              0      0   100%
tests/multi_tenant_b2c/multi_auth/test_auto_error.py      15      0   100%
tests/multi_tenant_b2c/test_multi_tenant.py              105      0   100%
tests/multi_tenant_b2c/test_settings.py                    8      1    88%   7
tests/single_tenant/__init__.py                            0      0   100%
tests/single_tenant/conftest.py                           35      0   100%
tests/single_tenant/test_single_tenant.py                111      0   100%
tests/test_exception_compat.py                            34      0   100%
tests/test_openapi_scheme.py                              34      0   100%
tests/test_provider_config.py                             55      2    96%   36-39
tests/test_user.py                                        15      0   100%
tests/utils.py                                            46      0   100%
------------------------------------------------------------------------------------
TOTAL                                                   1177     27    98%

see this article https://nedbatchelder.com/blog/202008/you_should_include_your_tests_in_coverage.html

davidhuser avatar Jun 10 '25 12:06 davidhuser

I don't disagree, but codecov don't seem to like pass in tests, such as the reported line 207, or line 7 in our settings test.

If there's better ways than adding a #noqa to them, I'd be very happy to accept a PR. I'm sure there's some dead code it catches too!

JonasKs avatar Jun 17 '25 08:06 JonasKs