[TIP] coverage.py and os.fork()?
Joe Malicki
jmalicki at gmail.com
Sun Mar 14 16:38:47 PDT 2010
Does anyone have a recipe of getting coverage.py to work across a fork()?
I was trying to use coverage 3.3.1 with python 2.6 and
multiprocessing, and couldn't figure out how to get it to trace the
child.
Attached is a simple test program to illustrate behavior and show
things I tried.
Is there another way of doing this I didn't come across, or is this
something that needs to be hacked into coverage?
Thanks!
Joe
with coverage run -p testcover.py, i see:
jmalicki at boott-spur:~$ coverage combine
jmalicki at boott-spur:~$ coverage report -m
Name Stmts Exec Cover Missing
-----------------------------------------
testcover 19 10 52% 10-20, 27
When I explicitly call stop: coverage run -p testcover.py -t
Child!
Traceback (most recent call last):
File "testcover.py", line 32, in <module>
main(sys.argv)
File "testcover.py", line 27, in main
child(args)
File "testcover.py", line 18, in child
coverage.stop()
File "/usr/local/lib/python2.6/dist-packages/coverage-3.3.1-py2.6-linux-x86_64.egg/coverage/__init__.py",
line 39, in wrapper
return getattr(_the_coverage, name)(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/coverage-3.3.1-py2.6-linux-x86_64.egg/coverage/control.py",
line 212, in stop
self.collector.stop()
File "/usr/local/lib/python2.6/dist-packages/coverage-3.3.1-py2.6-linux-x86_64.egg/coverage/collector.py",
line 214, in stop
assert self._collectors[-1] is self
AssertionError
coverage run -p testcover.py -s
Child!
jmalicki at boott-spur:~$ coverage combine
coverage report -m:
Name Stmts Exec Cover Missing
-----------------------------------------
testcover 19 10 52% 10-20, 27
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testcover.py
Type: application/octet-stream
Size: 462 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20100314/7fdf248a/attachment.obj>
More information about the testing-in-python
mailing list