[TIP] CTracer vs PyTracer in coverage.py 4.2; different behavior/caching?

Ned Batchelder ned at nedbatchelder.com
Sun Nov 13 17:41:03 PST 2016


Robert, this sounds involved and specific, so let's take it off-list.

--Ned.


On 11/13/16 2:14 AM, R M Waters wrote:
> Hi,
>
> I am attempting to run individual coverage reports for tests in a
> large suite in order to run some analysis on the suite.  I am using
> nose as the test runner, and executing the `erase()` and `start()`
> methods of `coverage.Coverage` between each test invocation in order
> to reset the coverage data.
>
> Some of our test methods follow the same branch pattern, but with
> different data (consider testing an encode/decode function with
> varying inputs).
>
> Using PyTracer, I can retrieve the coverage data for each test via
> `collector.data`.  This includes tests that have the same branch
> pattern (it will return same coverage data for those tests).
>
> However, using CTracer, I can retrieve coverage data only for the
> first invocation of a particular branch pattern.  Subsequent
> invocations return an empty dict.
>
> I have even tried replacing the entire `coverage.Coverage` object for
> each test, which should guarantee that all of the data and trace cache
> on the python side are purged, no dice though. Is CTracer a singleton?
>
> I can understand if this is an optimization; when running a coverage
> report for a test suite, this is all useless data.
>
> Is this expected behavior?  Am I going to have to go out of process,
> or is there an easier solution? 
>
> Thank you so much,
> Robert Waters
>
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20161113/935d30a3/attachment.htm>


More information about the testing-in-python mailing list