Copying a Mock object breaks coverage
There's a strange trifecta of misbehavior occurring when I copy a Mock object. Following the copy, coverage seems to no longer be able to keep track of coverage. I've attached a trivial program that reproduces the bug. easy_install mock if you don't already have it.
It's possible the root cause is in Mock or some weird interaction between Mock and copy. But unless they're doing something very unholy, it seems like it should not break coverage.
Neither --timid nor --branch helps.
I just checked the latest thing out from bitbucket,
I chucked trace.c since I didn't have a compiler installed.
Coverage.py, version 3.5a1. http://nedbatchelder.com/code/coverage/3.5a1
For what it's worth I also see this bug with the ancient version of coverage that comes with Eclipse PyDev.
<pre>jlaughlin@jlaughlin ~/tmp/coverage_bug $ coverage run --timid test_bug.py -v && coverage report -m copied a mock I was called! test_copy_mock (main.Test_1_copy_mock) ... ok test_a_trivial_function (main.Test_2_a_trivial_function) ... ok
Ran 2 tests in 0.017s
OK Name Stmts Miss Cover Missing
test_bug 14 3 79% 7, 12, 16
If you comment out line 11 in the program that copies the mock, coverage jumps to 100%.