1 year ago
#320650
Batters
CoverageWarning: No data was collected when installing module without -e flag
After installing all requirements and installing my_module
in editable mode with pip install -e .
, pytest
passes.
If I instead install my_module
with pip install .
, pytest
fails with:
============================================ test session starts =============================================
platform darwin -- Python 3.9.5, pytest-7.1.0, pluggy-1.0.0
rootdir: /Users/X/my_module, configfile: pyproject.toml, testpaths: tests
plugins: cov-3.0.0
collected 13 items
tests/end_to_end/test_end_to_end_example.py . [ 7%]
tests/integration/test_integration_example.py . [ 15%]
tests/unit/test_unit_example.py . [ 23%]
tests/unit/test_weather.py .......... [100%]/Users/X/my_module/lib/python3.9/site-packages/coverage/control.py:793: CoverageWarning: No data was collected. (no-data-collected)
self._warn("No data was collected.", slug="no-data-collected")
---------- coverage: platform darwin, python 3.9.5-final-0 -----------
Name Stmts Miss Cover Missing
-----------------------------------------------------
my_module/__init__.py 0 0 100%
my_module/constants.py 1 1 0% 4
my_module/calc.py 14 14 0% 4-54
-----------------------------------------------------
TOTAL 15 15 0%
FAIL Required test coverage of 100.0% not reached. Total coverage: 0.00%
============================================= 13 passed in 0.31s =============================================
my_module
has the following structure:
my_module
├── README.md
├── my_module
│ ├── __init__.py
│ ├── constants.py
│ ├── py.typed
│ └── calc.py
├── pyproject.toml
├── pyvenv.cfg
├── requirements.txt
├── setup.cfg
├── setup.py
└── tests
├── conftest.py
├── end_to_end
│ └── test_end_to_end_example.py
├── integration
│ └── test_integration_example.py
├── requirements.txt
└── unit
├── test_unit_example.py
└── test_calc.py
pyproject.toml
:
[build-system]
# The assumed default build requirements from pip are: "setuptools>=40.8.0",
# "wheel"
# See: https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
# These are taken from the PyScaffold example
# See: https://github.com/pyscaffold/pyscaffold-demo
requires = ["setuptools>=46.1.0", "setuptools_scm[toml]>=5", "wheel"]
build-backend = "setuptools.build_meta"
[tool.coverage.run]
source = [
"my_module/",
"*/site-packages/"
]
[tool.coverage.report]
show_missing = true
fail_under = 100
exclude_lines = ["pragma: not covered", "@overload"]
[tool.pytest.ini_options]
addopts = "--cov=my_module"
testpaths = "tests"
setup.cfg
:
[options]
zip_safe = False
include_package_data = True
packages = my_module
python_requires = >=3.7
install_requires =
attrs >=21.2
pandas >=1.3.4
python-dateutil >=2.8
requests >=2.26
titlecase >=2.3
[options.extras_require]
tests =
autoflake >=1.4
black >=22.1
flake8 >=4.0
isort >=5.10
mypy >=0.941
pre-commit >=2.17
pytest >=6.2
pytest-cov >=3.0
pyupgrade >=2.31
python
pytest
pytest-cov
0 Answers
Your Answer