Pytest finding package directory but not calculating coverage

42 views Asked by At

I am using pytest-cov to determine the coverage of my package. I have a directory structure that looks like this:

├── dev_environment.yaml
├── pyproject.toml
├── README.md
├── setup.py
├── src
└── testing

Where testing contains all the test scripts used for pytest and src contains my package files. The tree above is also at the root of the repo.

I have the line in my pyproject.toml:

[tool.pytest.ini_options]
addopts = "-p no:cacheprovider -v --cov=src/ --cov-report=term"

If i execute the command pytest at the root, i get the following output and error message

---------- coverage: platform linux, python 3.10.0-final-0 -----------
Name                          Stmts   Miss  Cover
-------------------------------------------------
src/__init__.py                 0      0   100%
src/file1.py                  179    179     0%
src/file2.py                  371    371     0%
-------------------------------------------------
TOTAL                          3070   3070     0%

where it finds the correct files under src, but there is no coverage generated. The error message

CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")

if i specify an absolute path to my package repo, everything works as expected. Seems like an issue with specifying a relative path?

0

There are 0 answers