jaraco / zipp

MIT License
61 stars 53 forks source link

CoverageWarning: Couldn't parse '.../(test)' #93

Closed mtelka closed 1 year ago

mtelka commented 1 year ago

python -m pytest reports the following coverage warning:

/usr/lib/python3.9/vendor-packages/coverage/report.py:114: CoverageWarning: Couldn't parse '/tmp/zipp-3.13.0/(test)': No source for code: '/tmp/zipp-3.13.0/(test)'. (couldnt-parse

The problem is caused by this line: https://github.com/jaraco/zipp/blob/v3.13.0/tests/test_zipp.py#L278

jaraco commented 1 year ago

I've encountered similar spurious errors from pytest-cov in https://github.com/pytest-dev/pytest-cov/issues/538.

jaraco commented 1 year ago

I am able to replicate the issue outside of pytest-cov:

 zipp main $ .tox/python/bin/coverage run .tox/python/bin/pytest -p no:cov
=========================================================================== test session starts ===========================================================================
platform darwin -- Python 3.11.1, pytest-7.2.1, pluggy-1.0.0
rootdir: /Users/jaraco/code/jaraco/zipp, configfile: pytest.ini
plugins: enabler-2.1.0, black-0.3.12, mypy-0.10.3, checkdocs-2.9.0, flake8-1.1.1
collected 77 items                                                                                                                                                        

conftest.py s..s                                                                                                                                                    [  5%]
. .                                                                                                                                                                 [  6%]
docs/conf.py s.s                                                                                                                                                    [ 10%]
tests/__init__.py s.s                                                                                                                                               [ 14%]
tests/_context.py ....                                                                                                                                              [ 19%]
tests/_func_timeout_compat.py ...                                                                                                                                   [ 23%]
tests/_test_params.py s.s                                                                                                                                           [ 27%]
tests/test_zipp.py ....s........................................                                                                                                    [ 86%]
zipp/__init__.py .......                                                                                                                                            [ 96%]
zipp/py310compat.py s.s                                                                                                                                             [100%]
================================================================================== mypy ===================================================================================

Success: no issues found in 9 source files
===================================================================== 65 passed, 11 skipped in 6.81s ======================================================================
 zipp main $ .tox/python/bin/coverage report
No source for code: '/Users/jaraco/code/jaraco/zipp/(test)'.
jaraco commented 1 year ago

It looks as if the proper fix for this general case of failures might be to suppress those 'couldnt-parse' warnings, but in this particular case, I believe the test is no longer adding any value, as it was there to address compatibility on Python 2, so I'll probably just remove the test.