coveragepy / coveragepy/coveragepy

`coverage combine` cannot find local plugin files

Open
#1,979 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
3.4k
Forks
525
Avg merge
18h 27m
Merged PRs (30d)
6

Description

Describe the bug
Consider a project:

pyproject.toml
my_local_plugin.py
src/
  foo.py
# pyproject.toml
[tool.coverage.run]
plugins = ["my_local_plugin"]
# my_local_plugin.py
def coverage_init(*args, **kwargs):
    pass

And then

# From project root directory (location of pyproject.toml)
$ coverage run foo.py
$ coverage combine
Traceback (most recent call last):
  File "/path/to/venv/bin/coverage", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/path/to/venv/lib/python3.13/site-packages/coverage/cmdline.py", line 970, in main
    status = CoverageScript().command_line(argv)
  File "/path/to/venv/lib/python3.13/site-packages/coverage/cmdline.py", line 681, in command_line
    return self.do_run(options, args)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/path/to/venv/lib/python3.13/site-packages/coverage/cmdline.py", line 855, in do_run
    self.coverage.start()
    ~~~~~~~~~~~~~~~~~~~^^
  File "/path/to/venv/lib/python3.13/site-packages/coverage/control.py", line 660, in start
    self._init()
    ~~~~~~~~~~^^
  File "/path/to/venv/lib/python3.13/site-packages/coverage/control.py", line 365, in _init
    self._plugins.load_from_config(self.config.plugins, self.config)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/venv/lib/python3.13/site-packages/coverage/plugin_support.py", line 48, in load_from_config
    __import__(module)
    ~~~~~~~~~~^^^^^^^^
ModuleNotFoundError: No module named 'my_local_plugin'

To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

  1. What version of Python are you using? 3.13
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.
$ coverage debug sys
-- sys -------------------------------------------------------
               coverage_version: 7.8.2
                coverage_module: /Users/jfaibussowit/soft/nv/legate.core.internal/venv/lib/python3.13/site-packages/coverage/__init__.py
                           core: -none-
                        CTracer: available from /Users/jfaibussowit/soft/nv/legate.core.internal/venv/lib/python3.13/site-packages/coverage/tracer.cpython-313-darwin.so
           plugins.file_tracers: -none-
            plugins.configurers: -none-
      plugins.context_switchers: -none-
              configs_attempted: /Users/jfaibussowit/soft/nv/.coveragerc
                                 /Users/jfaibussowit/soft/nv/setup.cfg
                                 /Users/jfaibussowit/soft/nv/tox.ini
                                 /Users/jfaibussowit/soft/nv/pyproject.toml
                   configs_read: -none-
                    config_file: None
                config_contents: -none-
                      data_file: -none-
                         python: 3.13.3 (main, Apr  8 2025, 13:54:08) [Clang 17.0.0 (clang-1700.0.13.3)]
                       platform: macOS-15.4.1-arm64-arm-64bit-Mach-O
                 implementation: CPython
                    gil_enabled: True
                     executable: /Users/jfaibussowit/soft/nv/legate.core.internal/venv/bin/python
                   def_encoding: utf-8
                    fs_encoding: utf-8
                            pid: 63286
                            cwd: /Users/jfaibussowit/soft/nv
                           path: /Users/jfaibussowit/soft/nv/legate.core.internal/venv/bin
                                 /opt/homebrew/Cellar/python@3.13/3.13.3_1/Frameworks/Python.framework/Versions/3.13/lib/python313.zip
                                 /opt/homebrew/Cellar/python@3.13/3.13.3_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13
                                 /opt/homebrew/Cellar/python@3.13/3.13.3_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/lib-dynload
                                 /Users/jfaibussowit/soft/nv/legate.core.internal/venv/lib/python3.13/site-packages
                    environment: HOME = /Users/jfaibussowit
                                 PYTHONBREAKPOINT = ipdb.set_trace
                   command_line: /Users/jfaibussowit/soft/nv/legate.core.internal/venv/bin/coverage debug sys
         sqlite3_sqlite_version: 3.49.2
             sqlite3_temp_store: 0
        sqlite3_compile_options: ATOMIC_INTRINSICS=1, COMPILER=clang-17.0.0, DEFAULT_AUTOVACUUM,
                                 DEFAULT_CACHE_SIZE=-2000, DEFAULT_FILE_FORMAT=4,
                                 DEFAULT_JOURNAL_SIZE_LIMIT=-1, DEFAULT_MMAP_SIZE=0, DEFAULT_PAGE_SIZE=4096,
                                 DEFAULT_PCACHE_INITSZ=20, DEFAULT_RECURSIVE_TRIGGERS,
                                 DEFAULT_SECTOR_SIZE=4096, DEFAULT_SYNCHRONOUS=2,
                                 DEFAULT_WAL_AUTOCHECKPOINT=1000, DEFAULT_WAL_SYNCHRONOUS=2,
                                 DEFAULT_WORKER_THREADS=0, DIRECT_OVERFLOW_READ, ENABLE_API_ARMOR,
                                 ENABLE_COLUMN_METADATA, ENABLE_DBSTAT_VTAB, ENABLE_FTS3,
                                 ENABLE_FTS3_PARENTHESIS, ENABLE_FTS5, ENABLE_MATH_FUNCTIONS,
                                 ENABLE_MEMORY_MANAGEMENT, ENABLE_PREUPDATE_HOOK, ENABLE_RTREE,
                                 ENABLE_SESSION, ENABLE_STAT4, ENABLE_UNLOCK_NOTIFY, MALLOC_SOFT_LIMIT=1024,
                                 MAX_ATTACHED=10, MAX_COLUMN=2000, MAX_COMPOUND_SELECT=500,
                                 MAX_DEFAULT_PAGE_SIZE=8192, MAX_EXPR_DEPTH=1000, MAX_FUNCTION_ARG=1000,
                                 MAX_LENGTH=1000000000, MAX_LIKE_PATTERN_LENGTH=50000,
                                 MAX_MMAP_SIZE=0x7fff0000, MAX_PAGE_COUNT=0xfffffffe, MAX_PAGE_SIZE=65536,
                                 MAX_SQL_LENGTH=1000000000, MAX_TRIGGER_DEPTH=1000,
                                 MAX_VARIABLE_NUMBER=250000, MAX_VDBE_OP=250000000, MAX_WORKER_THREADS=8,
                                 MUTEX_PTHREADS, SYSTEM_MALLOC, TEMP_STORE=1, THREADSAFE=1, USE_URI

Expected behavior
coverage should be able to import the package, using the current working directory. Setting PYTHONPATH=$(pwd) then of course it works.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in coverage/plugin_support.py at load_from_config, identified by the traceback, and reproduce the local-plugin configuration from the issue while running from the project root. Done means coverage can import my_local_plugin from the current working directory without requiring PYTHONPATH, while existing plugin loading behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.