recur(495) # We can get at least this many stack frames.
+ i = 8 # and this line will be traced
# We can't finish a very deep recursion, but we don't crash.
+ def test_long_recursion_recovery(self):
+ # Test the core of bug 93: http://bitbucket.org/ned/coveragepy/issue/93
+ # When recovering from a stack overflow, the Python trace function is
+ # disabled, but the C trace function is not. So if we're using a
+ # Python trace function, we won't trace anything after the stack
+ # overflow, and there should be a warning about it. If we're using
+ # the C trace function, only line 3 will be missing, and all else
+ self.make_file("recur.py", """\
+ recur(100000) # This is definitely too many frames.
+ cov = coverage.coverage()
+ pytrace = (cov.collector.tracer_name() == "PyTracer")
+ expected_missing += [9,10,11]
+ _, statements, missing, _ = cov.analysis("recur.py")
+ self.assertEqual(statements, [1,2,3,5,7,8,9,10,11])
+ self.assertEqual(missing, expected_missing)
+ # We can get a warning about the stackoverflow effect on the tracing
+ # function only if we have sys.gettrace
+ if pytrace and hasattr(sys, "gettrace"):
+ ["Trace function changed, measurement is likely wrong: None"]
+ self.assertEqual(cov._warnings, )
"""Attempt the impossible: test that memory doesn't leak."""