The following commands reproduce the bug:
pytest --cov module_1 --cov module_2 --cov module_3 --cov-fail-under=67 && echo "Exit code: $?"=================================================================================================================== test session starts ===================================================================================================================
platform darwin -- Python 3.12.12, pytest-9.0.1, pluggy-1.6.0
rootdir: /Users/dewringersam/Library/CloudStorage/OneDrive-TheBostonConsultingGroup,Inc/Documents/PycharmProjects/pytest-coverage-failure-mwe
configfile: pyproject.toml
plugins: cov-7.0.0
collected 2 items
tests/test_my_modules.py .. [100%]
===================================================================================================================== tests coverage ======================================================================================================================
____________________________________________________________________________________________________ coverage: platform darwin, python 3.12.12-final-0 ____________________________________________________________________________________________________
Name Stmts Miss Cover
---------------------------------------------
module_1/__init__.py 0 0 100%
module_1/my_module_1.py 3 0 100%
module_2/__init__.py 0 0 100%
module_2/my_module_2.py 3 0 100%
module_3/__init__.py 0 0 100%
module_3/my_module_3.py 3 3 0%
---------------------------------------------
TOTAL 9 3 67%
FAIL Required test coverage of 67% not reached. Total coverage: 66.67%
======================================================================================================== 2 passed in 0.04s ========================================================================================================
Exit code: 0