[TIP] coverage.py and os.fork()?

Ned Batchelder ned at nedbatchelder.com
Sat Mar 20 05:34:23 PDT 2010


Joe, I've fixed the os.fork issue, you can try the tip of 
http://bitbucket.org/ned/coveragepy/ to see if it works for you.

As for the nose plugin, it has long been a goal to take over development 
of the plugin so that it can keep pace with coverage.py itself.  I 
haven't gotten there yet, though...

--Ned.

Joe Malicki wrote:
> Thanks!
>
> Also, the next step is to get support for this into nose :)
>
> Right now, I can set parallel=True in a .coveragerc and use the
> attached patch to have nose
> call combine() before report().
>
> What's the right way  to do this longer term?  Should the cover.py
> nose plugin use the new-style
> coverage object (rather than module) interface so it can set some of
> the newer options?  I'll
> happily make it so as it's not much work, but I don't know if some are
> opposed to breaking
> compatibility with a new nose and pre-3.0 coverage.py (13 June 2009)?
>
> -joe
>
> On Mon, Mar 15, 2010 at 6:45 AM, Ned Batchelder <ned at nedbatchelder.com> wrote:
>   
>> Joe, I read your first email last night, and mulling over the possibilities,
>> concluded that the problem was just as you have diagnosed.  I awoke this
>> morning ready to fix it, and found you already had!  I'll apply the patch
>> today...
>>
>> Thanks.
>>
>> --Ned.
>>
>> Joe Malicki wrote:
>>
>> I dug in enough to realize it seemed to be a fairly fatal flaw of how
>> parallel=True was implemented.
>>
>> Issue and provisional patch that seem to work for me here:
>>
>> http://bitbucket.org/ned/coveragepy/issue/56/
>>
>> Thanks!
>> Joe
>>
>> On Sun, Mar 14, 2010 at 7:38 PM, Joe Malicki <jmalicki at gmail.com> wrote:
>>
>>
>> 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
>>
>>
>>
>> _______________________________________________
>> testing-in-python mailing list
>> testing-in-python at lists.idyll.org
>> http://lists.idyll.org/listinfo/testing-in-python
>>
>>     



More information about the testing-in-python mailing list