Error combining coverage when running with pytest-xdist and a custom coverage plugin
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- testing-qa
調査の方向性
Start in pytest_cov/engine.py, especially the finish path where Coverage.combine is called, and reproduce the issue with the provided pytest command, xdist workers, and custom coverage plugin configuration. Confirm the fix prevents the empty master-process coverage file from being created so combining worker data succeeds without the conflicting file tracer error.
索引モデルが issue の本文から書いたものです。
説明
Summary
I am working on a custom coverage plugin that returns custom file tracers for Python files. When I use this coverage plugin together with pytest-xdist, it fails when combining the coverage data from the xdist workers (see traceback below).
To debug this, I added keep=True to the calls to Coverage.combine in pytest_cov/engine.py.
In an example with three xdist workers:
- Four
.coverage.*files are created: one from each worker proceses, and one from the master process. - All four coverage files contain the same set of files in the "files" table.
- The coverage file generated from the master process has an empty "arc" table, and no entry in the "tracer" table.
When combining the coverage files, coverage checks if the "tracer" entries of all coverage files match. If a file is listed in the "files" table, but does not have an entry in the "tracer" table, it uses "" as the default tracer. This conflicts with the "tracer" info from the other data files, which causes coverage to error out.
To resolve this issue, pytest-cov could not create that extra, empty coverage data file from the master process.
Traceback
Traceback (most recent call last):
File "<venv_path>/lib/python3.10/site-packages/_pytest/main.py", line 271, in wrap_session
session.exitstatus = doit(config, session) or 0
File "<venv_path>/lib/python3.10/site-packages/_pytest/main.py", line 325, in _main
config.hook.pytest_runtestloop(session=session)
File "<venv_path>/lib/python3.10/site-packages/pluggy/_hooks.py", line 501, in __call__
return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
File "<venv_path>/lib/python3.10/site-packages/pluggy/_manager.py", line 119, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File "<venv_path>/lib/python3.10/site-packages/pluggy/_callers.py", line 155, in _multicall
teardown[0].send(outcome)
File "<venv_path>/lib/python3.10/site-packages/pytest_cov/plugin.py", line 339, in pytest_runtestloop
self.cov_controller.finish()
File "<venv_path>/lib/python3.10/site-packages/pytest_cov/engine.py", line 46, in ensure_topdir_wrapper
return meth(self, *args, **kwargs)
File "<venv_path>/lib/python3.10/site-packages/pytest_cov/engine.py", line 355, in finish
self.cov.combine()
File "<venv_path>/lib/python3.10/site-packages/coverage/control.py", line 836, in combine
combine_parallel_data(
File "<venv_path>/lib/python3.10/site-packages/coverage/data.py", line 179, in combine_parallel_data
data.update(new_data, aliases=aliases)
File "<venv_path>/lib/python3.10/site-packages/coverage/sqldata.py", line 760, in update
raise DataError(
coverage.exceptions.DataError: Conflicting file tracer name for '<project_path>/tests/test_example.py': '' vs 'example_plugin.ExampleCoveragePlugin'
Versions
Python 3.10.11 on Windows
coverage 7.4.4
pytest 7.4.3
pytest-cov 5.0.0
pytest-xdist 3.5.0
The same also fails on Linux with the same package versions.
Config
pytest is run via python -m pytest --cov --cov-config=pyproject.toml -v --numprocesses=3 --maxschedchunk=1.
coverage is configured as follows:
[tool.coverage.run]
branch = true
plugins = ["example_plugin"]
concurrency = ["thread", "multiprocessing"]
- 主要言語
- Python
- スター
- 2.1k
- フォーク
- 256
- 平均マージ
- 6日 10分
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytest-dev/pytest-cov のほかの issue
-
Celery tests require package; test blows up if Celery not installed instead of skipping the tests gracefully対応中かも @dchaudhari7177 が 103 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pytest-dev/pytest-cov#750 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pytest-dev/pytest-cov#617 · コメント 1 件 ·
-
Only set dynamic context on coveragepy cores supporting it, perhaps?対応中かも @terminalchai が 17 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
pytest-dev/pytest-cov#755 · コメント 3 件 ·
-
INTERNALERROR when generating html report using pytest-cov 7.1.0 with jinja対応中かも @daleselaji-dev が 89 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
pytest-dev/pytest-cov#748 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
pytest-dev/pytest-cov#747 · リアクション 1 件 ·
pytest-dev/pytest-cov の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SpikeInterface/spikeinterface#4924 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
aws-samples/sample-per-model-bedrock#782 ·
メンテナーはふだん 1 日以内に返信
-
bug javascript
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
No-op PreToolUse:Bash hook (bash_hook.py) still registered synchronously; adds latency and can time out at 10 s対応中かも @alexgr-agent が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
alexgreensh/token-optimizer#313 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100