Problem
Coverage numbers are systematically deflated and three modules are excluded outright. Root cause: the icap package registers a pytest11 entry-point plugin, so pytest imports the whole package during plugin loading, before pytest-cov starts measuring. Every module-level line (imports, def/class statements, decorators, constants) is recorded as missed, and the config works around it by omitting __init__.py, exception.py, and _protocol.py ('executed before coverage starts').
The _protocol.py omit is now costly: since the shared-logic refactor it contains core parsing/validation (parse_chunk_size, parse_response_headers, _validate_service_name, prepare_preview_data) with zero coverage visibility.
Validated fix
Run pytest under coverage so measurement starts at interpreter level, before plugin loading:
coverage run -m pytest -m 'not integration'
coverage combine
coverage report / coverage xml
Measured on the same test run (unit tests only), before → after:
| Module |
pytest-cov |
coverage run |
icap.py |
85% |
92% |
response.py |
61% |
93% |
__init__.py |
omitted |
100% |
exception.py |
omitted |
100% |
_protocol.py |
omitted |
98% |
Remaining missing lines after the switch are genuine behavioral gaps (tracked separately), not import-time noise.
Changes
Problem
Coverage numbers are systematically deflated and three modules are excluded outright. Root cause: the
icappackage registers a pytest11 entry-point plugin, so pytest imports the whole package during plugin loading, before pytest-cov starts measuring. Every module-level line (imports,def/classstatements, decorators, constants) is recorded as missed, and the config works around it by omitting__init__.py,exception.py, and_protocol.py('executed before coverage starts').The
_protocol.pyomit is now costly: since the shared-logic refactor it contains core parsing/validation (parse_chunk_size,parse_response_headers,_validate_service_name,prepare_preview_data) with zero coverage visibility.Validated fix
Run pytest under coverage so measurement starts at interpreter level, before plugin loading:
Measured on the same test run (unit tests only), before → after:
icap.pyresponse.py__init__.pyexception.py_protocol.pyRemaining missing lines after the switch are genuine behavioral gaps (tracked separately), not import-time noise.
Changes
noxfile.pycoverage sessions: replacepytest --cov=src/icapwithcoverage run -m pytest+coverage combine+coverage report --show-missing+coverage xml(config already hasparallel = true); drop the pytest-cov dep from those sessions.omitentries for__init__.py,exception.py,_protocol.pyinpyproject.toml.-n auto): addpatch = ["subprocess"]to[tool.coverage.run](requires coverage >= 7.10; lockfile has 7.13.4) so worker processes are measured from interpreter startup too.fail_under(~85%) once the numbers are trustworthy.