How to run coverage report with parallel pytest using xdist and django_coverage_plugin

Viewed 234

Using the following setup, the calculated coverage is less than if I use a single thread without parallelization. Coverage creates only 1 coverage file in the project root directory, which I expect is where the problem lies.

I cannot identify what I am doing wrong, the reported coverage is less than if I simply run coverage -m pytest (on a single thread). The tests themselves run in parallel just fine.

Can anyone identify my mistake? I wonder if an environment variable is missing. I run the command from the project root, which contains .coveragerc and sitecustomize.py.

coverage erase && COVERAGE_PROCESS_START=./.coveragerc coverage run --concurrency=multiprocessing --parallel-mode -m pytest -n 8 && coverage combine && coverage report

sitecustomize.py

import coverage

coverage.process_startup()

.coveragerc

[run]
include = 
    lettergun/*
omit = 
    *migrations*
    *tests*
    *.html
plugins = django_coverage_plugin
parallel = True
concurrency = multiprocessing
branch = True

pytest.ini

[pytest]
addopts = --ds=config.settings.test --reuse-db -n 8
python_files = test_*.py
norecursedirs = node_modules
DJANGO_SETTINGS_MODULE = config.settings.test
0 Answers
Related