Closed matveypashkovskiy closed 3 years ago
Looking at the trace, the tool calculates the test file path from the single pytest item it finds and tries to read the source code for it with Coverage.py to define where the test function starts and ends. coverage.misc.NoSource
is thrown if it can't find the file for some reason. I can't get this example project to fail. I did the following:
cd pytest_rts_cov/
git init
git add .
git commit -m "initial"
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
make test-rts
And got a succesful run:
. .venv/bin/activate; pytest -x \
--rts \
--cov-config=.coveragerc \
--cov=pytest_rts_cov \
--cov-report=html \
--cov-report=term \
# --cov-fail-under=89.8
No mapping database detected, starting initialization...
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.8.5, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /home/eero/Desktop/pytest_rts_cov
plugins: cov-2.11.1, rts-1.1.10
collected 1 item
pytest_rts_cov/tests/foo_test.py . [100%]
----------- coverage: platform linux, python 3.8.5-final-0 -----------
Name Stmts Miss Cover
------------------------------------------------
pytest_rts_cov/__init__.py 0 0 100%
pytest_rts_cov/bar.py 3 3 0%
pytest_rts_cov/foo.py 3 1 67%
------------------------------------------------
TOTAL 6 4 33%
Coverage HTML written to dir htmlcov
Hm, could you try with Python 3.6?
Ok, looks like the problem is in type hints. When I removed them from the code it start to work with both versions.
Created a small project to reproduce coverage percentage problem but run into problems during the mapping database initialization.
If I run
make test-rts
it fails with:It looks like a config problem of coverage.py.