Pytest cov is not reading its setting from the pyproject.toml file. I am using nox, so I run the test with:
python3 -m nox
It seems I have the same issue even without nox.
In fact, after running a poetry install
:
poetry run pytest --cov=src
passes the testpoetry run pytest --cov
does not pass the test
In particular, when failing the test I have the following output (output is cut to the most important stuff):
WARNING: Failed to generate report: No data to report.
/Users/matteo/Library/Caches/pypoetry/virtualenvs/project-Nz69kfmJ-py3.7/lib/python3.7/site-packages/pytest_cov/plugin.py:271: PytestWarning: Failed to generate report: No data to report.
self.cov_controller.finish()
---------- coverage: platform darwin, python 3.7.7-final-0 -----------
FAIL Required test coverage of 100.0% not reached. Total coverage: 0.00%
Code with a reproducible error here. To run it you'll need to install poetry and to install nox.
src
layout wrong. The meaning of thesrc
dir is to avoid accidental imports of the code from repository, ensuring the package is always installed.poetry
supportssrc
layout; in your case, you'd have to addpackages = [{ include = 'project', from = 'src' }]
to thetool.poetry
section andsource = ['project']
totool.coverage.run
. – Fieldpiecesrc
dir completely if you don't need thesrc
layout. Anyway,from src.project import code
should be fixed. Your root package isproject
, notsrc
. – Fieldpiece