[TIP] CTracer vs PyTracer in coverage.py 4.2; different behavior/caching?
R M Waters
robert.waters at gmail.com
Sat Nov 12 23:14:46 PST 2016
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
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,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python