I'm using nose
to run my "unittest" tests and have nose-cov
to include coverage reports. These all work fine, but part of my tests require running some code as a multiprocessing.Process
. The nose-cov
docs state that it can do multiprocessing
, but I'm not sure how to get that to work.
I'm just running tests by running nosetests
and using the following .coveragerc
:
[run]
branch = True
parallel = True
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain about missing debug-only code:
def __repr__
#if self\.debug
# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
def __main__\(\):
omit =
mainserver/tests/*
EDIT:
I fixed the parallel
switch in my ".coveragerc" file. I've also tried adding a sitecustomize.py
like so in my site-packages directory:
import os
import coverage
os.environ['COVERAGE_PROCESS_START']='/sites/metrics_dev/.coveragerc'
coverage.process_startup()
I'm pretty sure it's still not working properly, though, because the "missing" report still shows lines that I know are running (they output to the console). I've also tried adding the environment variable in my test case file and also in the shell before running the test cases. I also tried explicitly calling the same things in the function that's called by multiprocessing.Process
to start the new process.
--parallel-mode
so I assumed that's what it was in the config. Thanks for pointing out that page, I'll see if I can get that working. And thanks for developing such a great testing tool! – Strage