Issue #10992: make tests pass when run under coverage.
Various tests fail when run under coverage. A primary culprit is refcount tests
which fail as the counts are thrown off by the coverage code. A new decorator
-- test.support.refcount_test -- is used to decorate tests which test refcounts
and to skip them when running under coverage. Other tests simply fail because
of changes in the system (e.g., __local__ suddenly appearing).
Thanks to Kristian Vlaardingerbroek for helping to diagnose the test failures.
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index 0e5a397..f60d5d9 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -1,5 +1,6 @@
import unittest
-from test.support import verbose, run_unittest, strip_python_stderr
+from test.support import (verbose, refcount_test, run_unittest,
+ strip_python_stderr)
import sys
import gc
import weakref
@@ -175,6 +176,7 @@
del d
self.assertEqual(gc.collect(), 2)
+ @refcount_test
def test_frame(self):
def f():
frame = sys._getframe()
@@ -242,6 +244,7 @@
# For example:
# - disposed tuples are not freed, but reused
# - the call to assertEqual somehow avoids building its args tuple
+ @refcount_test
def test_get_count(self):
# Avoid future allocation of method object
assertEqual = self._baseAssertEqual
@@ -252,6 +255,7 @@
# the dict, and the tuple returned by get_count()
assertEqual(gc.get_count(), (2, 0, 0))
+ @refcount_test
def test_collect_generations(self):
# Avoid future allocation of method object
assertEqual = self.assertEqual