coverage in parallel for django tests










7















I am running the following through a 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% test coverage of all files within app. However, if NPROCS is greater than 1, I get lots of missing lines in my report.



What am I doing wrong?



My .coveragerc-app is as follows:



# 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__.:









share|improve this question

















  • 1





    I'll guess that you don't have subprocesses being measured properly. You can examine the data files that are produced during the run. How many do you get, and what lines are they covering? You can see a summary of the data with: "COVERAGE_FILE=the_data_file coverage debug data"

    – Ned Batchelder
    Mar 10 '17 at 19:10











  • @NedBatchelder I only get one file .coverage.serval.TLD.12116.528573 which only contains part of the data. The final report is indeed correct and matches the data in that one file. I am assuming that there should be X (=NPROCS) files. I wonder if it is the django plugin that is not working right?…

    – Sardathrion
    Mar 13 '17 at 14:30















7















I am running the following through a 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% test coverage of all files within app. However, if NPROCS is greater than 1, I get lots of missing lines in my report.



What am I doing wrong?



My .coveragerc-app is as follows:



# 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__.:









share|improve this question

















  • 1





    I'll guess that you don't have subprocesses being measured properly. You can examine the data files that are produced during the run. How many do you get, and what lines are they covering? You can see a summary of the data with: "COVERAGE_FILE=the_data_file coverage debug data"

    – Ned Batchelder
    Mar 10 '17 at 19:10











  • @NedBatchelder I only get one file .coverage.serval.TLD.12116.528573 which only contains part of the data. The final report is indeed correct and matches the data in that one file. I am assuming that there should be X (=NPROCS) files. I wonder if it is the django plugin that is not working right?…

    – Sardathrion
    Mar 13 '17 at 14:30













7












7








7


1






I am running the following through a 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% test coverage of all files within app. However, if NPROCS is greater than 1, I get lots of missing lines in my report.



What am I doing wrong?



My .coveragerc-app is as follows:



# 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__.:









share|improve this question














I am running the following through a 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% test coverage of all files within app. However, if NPROCS is greater than 1, I get lots of missing lines in my report.



What am I doing wrong?



My .coveragerc-app is as follows:



# 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__.:






django coverage.py






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 10 '17 at 15:23









SardathrionSardathrion

6,2231360100




6,2231360100







  • 1





    I'll guess that you don't have subprocesses being measured properly. You can examine the data files that are produced during the run. How many do you get, and what lines are they covering? You can see a summary of the data with: "COVERAGE_FILE=the_data_file coverage debug data"

    – Ned Batchelder
    Mar 10 '17 at 19:10











  • @NedBatchelder I only get one file .coverage.serval.TLD.12116.528573 which only contains part of the data. The final report is indeed correct and matches the data in that one file. I am assuming that there should be X (=NPROCS) files. I wonder if it is the django plugin that is not working right?…

    – Sardathrion
    Mar 13 '17 at 14:30












  • 1





    I'll guess that you don't have subprocesses being measured properly. You can examine the data files that are produced during the run. How many do you get, and what lines are they covering? You can see a summary of the data with: "COVERAGE_FILE=the_data_file coverage debug data"

    – Ned Batchelder
    Mar 10 '17 at 19:10











  • @NedBatchelder I only get one file .coverage.serval.TLD.12116.528573 which only contains part of the data. The final report is indeed correct and matches the data in that one file. I am assuming that there should be X (=NPROCS) files. I wonder if it is the django plugin that is not working right?…

    – Sardathrion
    Mar 13 '17 at 14:30







1




1





I'll guess that you don't have subprocesses being measured properly. You can examine the data files that are produced during the run. How many do you get, and what lines are they covering? You can see a summary of the data with: "COVERAGE_FILE=the_data_file coverage debug data"

– Ned Batchelder
Mar 10 '17 at 19:10





I'll guess that you don't have subprocesses being measured properly. You can examine the data files that are produced during the run. How many do you get, and what lines are they covering? You can see a summary of the data with: "COVERAGE_FILE=the_data_file coverage debug data"

– Ned Batchelder
Mar 10 '17 at 19:10













@NedBatchelder I only get one file .coverage.serval.TLD.12116.528573 which only contains part of the data. The final report is indeed correct and matches the data in that one file. I am assuming that there should be X (=NPROCS) files. I wonder if it is the django plugin that is not working right?…

– Sardathrion
Mar 13 '17 at 14:30





@NedBatchelder I only get one file .coverage.serval.TLD.12116.528573 which only contains part of the data. The final report is indeed correct and matches the data in that one file. I am assuming that there should be X (=NPROCS) files. I wonder if it is the django plugin that is not working right?…

– Sardathrion
Mar 13 '17 at 14:30












2 Answers
2






active

oldest

votes


















10














You miss a few steps, from Measuring sub-processes:



1) 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


2) Create a file named sitecustomize.py in your local folder with



import coverage
coverage.process_startup()


3) Add concurrency option in your rcfile:



concurrency=multiprocessing





share|improve this answer

























  • Happy to read that ! I have removed the fact that it may be optional

    – feydaykyn
    Mar 30 '17 at 11:59











  • This is saving me lots of time… Many thanks indeed.

    – Sardathrion
    Mar 30 '17 at 11:59


















1














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.






share|improve this answer


















  • 1





    Urgh. That's lame. My tests take around 10/15 minutes to all run so parallel running is kinda needed.

    – Sardathrion
    Nov 16 '18 at 8:30










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42721896%2fcoverage-in-parallel-for-django-tests%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









10














You miss a few steps, from Measuring sub-processes:



1) 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


2) Create a file named sitecustomize.py in your local folder with



import coverage
coverage.process_startup()


3) Add concurrency option in your rcfile:



concurrency=multiprocessing





share|improve this answer

























  • Happy to read that ! I have removed the fact that it may be optional

    – feydaykyn
    Mar 30 '17 at 11:59











  • This is saving me lots of time… Many thanks indeed.

    – Sardathrion
    Mar 30 '17 at 11:59















10














You miss a few steps, from Measuring sub-processes:



1) 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


2) Create a file named sitecustomize.py in your local folder with



import coverage
coverage.process_startup()


3) Add concurrency option in your rcfile:



concurrency=multiprocessing





share|improve this answer

























  • Happy to read that ! I have removed the fact that it may be optional

    – feydaykyn
    Mar 30 '17 at 11:59











  • This is saving me lots of time… Many thanks indeed.

    – Sardathrion
    Mar 30 '17 at 11:59













10












10








10







You miss a few steps, from Measuring sub-processes:



1) 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


2) Create a file named sitecustomize.py in your local folder with



import coverage
coverage.process_startup()


3) Add concurrency option in your rcfile:



concurrency=multiprocessing





share|improve this answer















You miss a few steps, from Measuring sub-processes:



1) 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


2) Create a file named sitecustomize.py in your local folder with



import coverage
coverage.process_startup()


3) Add concurrency option in your rcfile:



concurrency=multiprocessing






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 30 '17 at 11:59

























answered Mar 17 '17 at 16:24









feydaykynfeydaykyn

42647




42647












  • Happy to read that ! I have removed the fact that it may be optional

    – feydaykyn
    Mar 30 '17 at 11:59











  • This is saving me lots of time… Many thanks indeed.

    – Sardathrion
    Mar 30 '17 at 11:59

















  • Happy to read that ! I have removed the fact that it may be optional

    – feydaykyn
    Mar 30 '17 at 11:59











  • This is saving me lots of time… Many thanks indeed.

    – Sardathrion
    Mar 30 '17 at 11:59
















Happy to read that ! I have removed the fact that it may be optional

– feydaykyn
Mar 30 '17 at 11:59





Happy to read that ! I have removed the fact that it may be optional

– feydaykyn
Mar 30 '17 at 11:59













This is saving me lots of time… Many thanks indeed.

– Sardathrion
Mar 30 '17 at 11:59





This is saving me lots of time… Many thanks indeed.

– Sardathrion
Mar 30 '17 at 11:59













1














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.






share|improve this answer


















  • 1





    Urgh. That's lame. My tests take around 10/15 minutes to all run so parallel running is kinda needed.

    – Sardathrion
    Nov 16 '18 at 8:30















1














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.






share|improve this answer


















  • 1





    Urgh. That's lame. My tests take around 10/15 minutes to all run so parallel running is kinda needed.

    – Sardathrion
    Nov 16 '18 at 8:30













1












1








1







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 18:22









YPCrumbleYPCrumble

9,872965118




9,872965118







  • 1





    Urgh. That's lame. My tests take around 10/15 minutes to all run so parallel running is kinda needed.

    – Sardathrion
    Nov 16 '18 at 8:30












  • 1





    Urgh. That's lame. My tests take around 10/15 minutes to all run so parallel running is kinda needed.

    – Sardathrion
    Nov 16 '18 at 8:30







1




1





Urgh. That's lame. My tests take around 10/15 minutes to all run so parallel running is kinda needed.

– Sardathrion
Nov 16 '18 at 8:30





Urgh. That's lame. My tests take around 10/15 minutes to all run so parallel running is kinda needed.

– Sardathrion
Nov 16 '18 at 8:30

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42721896%2fcoverage-in-parallel-for-django-tests%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党