Error combining coverage when running with pytest-xdist and a custom coverage plugin
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- testing-qa
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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"]
- Lenguaje dominante
- Python
- Estrellas
- 2.1k
- Forks
- 253
- Merge medio
- 6 d 10 min
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pytest-dev/pytest-cov
-
Celery tests require package; test blows up if Celery not installed instead of skipping the tests gracefullyPosiblemente ocupada @dchaudhari7177 la tomó hace 100 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
pytest-dev/pytest-cov#750 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
pytest-dev/pytest-cov#617 · 1 comentario ·
-
Only set dynamic context on coveragepy cores supporting it, perhaps?Posiblemente ocupada @terminalchai la tomó hace 15 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
pytest-dev/pytest-cov#755 · 3 comentarios ·
-
INTERNALERROR when generating html report using pytest-cov 7.1.0 with jinjaPosiblemente ocupada @daleselaji-dev la tomó hace 87 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
pytest-dev/pytest-cov#748 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 28/100
pytest-dev/pytest-cov#747 · 1 reacción ·
Todos los issues de pytest-dev/pytest-cov
Issues similares
-
DBFS append mode silently overwrites existing filesPosiblemente ocupada @IlyaKhalafi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
fsspec/filesystem_spec#2429 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
volcengine/OpenViking#7014 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
fedora-copr/copr#4600 ·
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ansys/pydpf-core#3620 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día