Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report.py Tries to parse non-existent files #539

Closed
adam-grant-hendry opened this issue Jun 7, 2022 · 3 comments
Closed

report.py Tries to parse non-existent files #539

adam-grant-hendry opened this issue Jun 7, 2022 · 3 comments

Comments

@adam-grant-hendry
Copy link

Summary

After uninstalling PyQt5 and installing PySide6 in my virtual environment (using poetry add/remove), coverage reports warnings that it cannot parse some non-existent files. It is looking for site-packages pyscript, shibokensupport, and signature_bootstrap.py as if they are in my local folder, when they are actually in my .venv/Lib/site-packages folder:

%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\pyscript': No source for code: '%userprofile%\Code\myproj\pyscript'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\__init__.py': No source for 
code: '%userprofile%\Code\myproj\shibokensupport\__init__.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\feature.py': No source for code: '%userprofile%\Code\myproj\shibokensupport\feature.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\__init__.py': No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\__init__.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\errorhandler.py': 
No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\errorhandler.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\importhandler.py': No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\importhandler.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\layout.py': No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\layout.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\lib\__init__.py': 
No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\lib\__init__.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\lib\enum_sig.py': 
No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\lib\enum_sig.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\lib\pyi_generator.py': No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\lib\pyi_generator.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\lib\tool.py': No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\lib\tool.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\loader.py': No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\loader.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\mapping.py': No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\mapping.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\shibokensupport\signature\parser.py': No source for code: '%userprofile%\Code\myproj\shibokensupport\signature\parser.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")
%userprofile%\code\myproj\.venv\lib\site-packages\coverage\report.py:87: CoverageWarning: Couldn't parse '%userprofile%\Code\myproj\signature_bootstrap.py': No source for code: '%userprofile%\Code\myproj\signature_bootstrap.py'. (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")

Expected vs actual result

Expect coverage not to search for non-existent files and to not warn.

Reproducer

  1. Create and activate a virtual environment

    PS> py -m venv .venv
    PS> .venv/Scripts/Activate.ps1

    and ensure vscode sees the Python Interpreter (use Ctrl+Shift+p and set).

  2. Create a new poetry project

    PS> poetry init
  3. Install pytest, pytest-cov, pytest-env, pytest-qt, pyqt5, and qtpy

    PS> poetry add pytest pytest-cov pytest-qt pyqt5 qtpy
  4. Update the pyproject.toml and then run poetry install to make a local (editable) install

    [tool.poetry]
    name = "coverage-issue-1392"
    version = "0.1.0"
    description = ""
    authors = ["Hendry, Adam <adam.grant.hendry@gmail.com>"]
    packages = [
        {include = "myproj"},
        {include = "tests"}
    ]
    
    [tool.poetry.dependencies]
    PyQt5 = "^5.15.6"
    pytest = "^7.1.2"
    pytest-cov = "^3.0.0"
    pytest-env = "^0.6.2"
    pytest-qt = "^4.0.2"
    python = "3.8"
    QtPy = "^2.1.0"
    
    [tool.poetry.dev-dependencies]
    
    [build-system]
    requires = ["poetry-core>=1.0.0"]
    build-backend = "poetry.core.masonry.api"
    
    [tool.pytest.ini_options]
    minversion = "7.0"
    addopts = """\
    --last-failed --last-failed-no-failures all \
    -p no:faulthandler \
    --import-mode=importlib \
    --cov \
    --cov-report term-missing \
    --cov-report html \
    --cov-report xml \
    """
    testpaths = [
        "tests",
    ]
    qt_api = "pyqt5"
    env = [
        "D:COVERAGE_DEBUG=trace",
        "D:COVERAGE_DEBUG_FILE=debug_log.txt"
    ]
  5. Create a dummy Qt project

    myproj/main.py
    from qtpy import QtWidgets
    
    
    class MainApp(QtWidgets.QMainWindow):
        """The main window."""
    
    if __name__ == '__main__':
        app = QtWidgets.QApplication([])
        window = MainApp()
        window.show()
        app.exec_()
  6. Create a dummy test

    test/test_window.py
    import pytest
    from myproj.main import MainApp
    
    
    @pytest.fixture(name='app', scope='function')
    def fixture_app(qtbot):
        window = MainApp()
        window.show()
    
        qtbot.addWidget(window)
    
        yield window
    
    def test_window_appears(app) -> None:
        assert app.isVisible()
  7. Run pytest

    PS> pytest
  8. Add pyside6 and remove pyqt5

       PS> poetry add pyside6
       PS> poetry remove pyqt5

    NOTE: Before doing this, be sure to set python exactly to 3.8 in the pyproject.toml:

    python = "3.8"
  9. Change qt_api in pyproject.toml:

    [tool.pytest.ini_options]
    qt_api = "pyside6"
  10. Update project with new toml

    PS> poetry update
  11. Re-run pytest

    PS> pytest

This generates the error messages mentioned.

Versions

OS: Windows 10
Python: 3.8.10
VSCode: 1.67.2

Config

N/A (see Reproducer)

Code

N/A (see Reproducer)

@nedbat
Copy link
Collaborator

nedbat commented Jun 7, 2022

You already wrote a bug against coverage.py (nedbat/coveragepy#1392), why write this one here?

@nedbat
Copy link
Collaborator

nedbat commented Jun 8, 2022

Sorry, maybe it's not clear: pytest-cov is a plugin that uses coverage.py as its engine. This bug is a duplicate.

@nedbat nedbat closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2022
@adam-grant-hendry
Copy link
Author

@nedbat I wrote this here in the event the coveragepy maintainers would tell me to open an issue on pytest-cov instead. Thank you for closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants