26👍
✅
You miss a few steps, from Measuring sub-processes:
- change the coverage run command to this one :
COVERAGE_PROCESS_START=./.coveragerc-app coverage run
--parallel-mode --concurrency=multiprocessing
--rcfile=./.coveragerc-app manage.py test -v 3 --parallel=$(NPROCS) app
- Create a file named sitecustomize.py in your local folder with
import coverage
coverage.process_startup()
- Add concurrency option in your rcfile (run section):
concurrency=multiprocessing
8👍
Took a read through the coverage documentation linked in answer above, perhaps it’s been updated, as just doing the following seems to work for our Django project:
coverage run --concurrency=multiprocessing manage.py test app --parallel=3
coverage combine
coverage report
- How to specify uniqueness for a tuple of field in a Django model
- Clean Up HTML in Python
- Why swagger raises unclear error – Django
- How to populate user profile with django-allauth provider information?
3👍
Per the documentation:
Coverage should be run in a single process to obtain accurate statistics.
Not an answer to this question but for those looking to optimize their project in this manner it may be helpful to know it isn’t recommended by Django maintainers.
- Django template tag: How to send next_page in {url auth_logout}?
- Celery – No module named five
- Django ForeignKey limit_choices_to a different ForeignKey id
- Django. Error message for login form
- Have a url that accepts all characters
0👍
I have something like this:
function cpu_count() {
python -c 'import multiprocessing; print(multiprocessing.cpu_count())'
}
function apps() {
python -c "from website import apps; print(' '.join(apps.LOCAL_APPS))"
}
export $(cat envs/.env.development | xargs)
rm -rf htmlcov &&\
coverage run --concurrency=multiprocessing\
manage.py test --parallel $(cpu_count) $(apps) $@ &&\
coverage combine &&\
coverage html
- Creation of dynamic model fields in django
- Using existing field values in django update query
- Django unable to find MySQLdb python module
- Installing django 1.5(development version) in virtualenv
Source:stackexchange.com