-
Notifications
You must be signed in to change notification settings - Fork 231
Closed as not planned
Closed as not planned
Copy link
Description
A cv2 import statement has pytest-cov looking for two source files in cwd instead of in site-packages/cv2.
So two warnings are issued, because coverage doesn't find config.py and config-3.py.
(hmmm, now that I've typed this up, I'm wondering if this can be narrowed to coverage itself, instead of pytest-cov. Sorry, at this time I don't know).
Expected result:
no warnings
Actual result, for the simple "reproducer":
============================= test session starts ==============================
platform darwin -- Python 3.10.11, pytest-8.4.2, pluggy-1.6.0
rootdir: /Users/john/simple-test-case
plugins: cov-7.0.0
collected 1 item
test_import_cv2.py .
/Users/john/venvs/3.10+cv2+pytest/lib/python3.10/site-packages/coverage/report_core.py:113: CoverageWarning: Couldn't parse '/Users/john/simple-test-case/config-3.py': No source for code: '/Users/john/simple-test-case/config-3.py'. (couldnt-parse); see https://coverage.readthedocs.io/en/7.10.7/messages.html#warning-couldnt-parse
coverage._warn(msg, slug="couldnt-parse")
/Users/john/venvs/3.10+cv2+pytest/lib/python3.10/site-packages/coverage/report_core.py:113: CoverageWarning: Couldn't parse '/Users/john/simple-test-case/config.py': No source for code: '/Users/john/simple-test-case/config.py'. (couldnt-parse); see https://coverage.readthedocs.io/en/7.10.7/messages.html#warning-couldnt-parse
coverage._warn(msg, slug="couldnt-parse")
[100%]
================================ tests coverage ================================
______________ coverage: platform darwin, python 3.10.11-final-0 _______________
Name Stmts Miss Cover
----------------------------------------
test_import_cv2.py 3 0 100%
----------------------------------------
TOTAL 3 0 100%
============================== 1 passed in 0.57s ===============================
Reproducer
-
Create a new venv
-
activate the new venv, and
pip install opencv-python
pip install pytest
pip install pytest-cov
- create a simple test file,
test_import_cv2.py
import cv2
def test_dummy():
pass
- Then, this
pytest --cov=. test_import_cv2.py
produces the output provided above.
Versions
pip list reports
Package Version
----------------- ---------
coverage 7.10.7
exceptiongroup 1.3.0
iniconfig 2.1.0
numpy 2.2.6
opencv-python 4.12.0.88
packaging 25.0
pip 23.0.1
pluggy 1.6.0
Pygments 2.19.2
pytest 8.4.2
pytest-cov 7.0.0
setuptools 65.5.0
tomli 2.2.1
typing_extensions 4.15.0
pytest output begins with
============================= test session starts ==============================
platform darwin -- Python 3.10.11, pytest-8.4.2, pluggy-1.6.0
rootdir: /Users/john/simple-test-case
plugins: cov-7.0.0
Config
no tox.ini, pytest.ini, .coveragerc, setup.cfg or any relevant configuration.
Code
(pasted above)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels