Coverage in parallel for django tests

I do the following through the Makefiel :

 NPROCS:=$(shell /usr/bin/nproc) .PHONY: coverage-app coverage-app: coverage erase --rcfile=./.coveragerc-app coverage run --parallel-mode --rcfile=./.coveragerc-app manage.py test -v 3 --parallel=$(NPROCS) app coverage combine --rcfile=./.coveragerc-app coverage report -m --rcfile=./.coveragerc-app 

If I set NPROCS to 1, I get the expected 100% coverage of all files in the app . However, if NPROCS greater than 1, I get many missing lines in my report.

What am I doing wrong?

My .coveragerc-app looks like this:

 # Control coverage.py [run] branch = True omit = */__init__* */test*.py */migrations/* */urls.py app/admin.py app/apps.py source = app parallel = true [report] precision = 1 show_missing = True ignore_errors = True exclude_lines = pragma: no cover raise NotImplementedError except ImportError def __repr__ if self\.logger\.debug if __name__ == .__main__.: 
+5
source share
1 answer

You will skip a few steps, from Measuring Subprocesses :

1) change the coverage launch command to this:

 COVERAGE_PROCESS_START=./.coveragerc-app coverage run --parallel-mode --concurrency=multiprocessing --rcfile=./.coveragerc-app manage.py test -v 3 --parallel=$(NPROCS) app 

2) Create a file called sitecustomize.py in a local folder using

 import coverage coverage.process_startup() 

3) Add the concurrency parameter to your rcfile:

 concurrency=multiprocessing 
+7
source

Source: https://habr.com/ru/post/1265299/


All Articles