From d8bcbf2b2ecca3cf168718d50dc46ba5775b0bc9 Mon Sep 17 00:00:00 2001 From: Amaury Forgeot d'Arc Date: Fri, 15 Feb 2008 22:44:20 +0000 Subject: Re-enable tests, they were failing since gc.collect() clears the various freelists. They still remain fragile. For example, a call to assertEqual currently does not make any allocation (which surprised me at first). But this can change when gc.collect also deletes the numerous "zombie frames" attached to each function. --- Lib/test/test_gc.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 9abf285..6e2ea41 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -236,23 +236,33 @@ class GCTests(unittest.TestCase): gc.disable() gc.set_threshold(*thresholds) + # The following two tests are fragile: + # They precisely count the number of allocations, + # which is highly implementation-dependent. + # For example: + # - disposed tuples are not freed, but reused + # - the call to assertEqual somehow avoids building its args tuple def test_get_count(self): - return # disable temporarily + # Avoid future allocation of method object + assertEqual = self.assertEqual gc.collect() - self.assertEqual(gc.get_count(), (0, 0, 0)) + assertEqual(gc.get_count(), (0, 0, 0)) a = dict() - self.assertEqual(gc.get_count(), (1, 0, 0)) + # since gc.collect(), we created two objects: + # the dict, and the tuple returned by get_count() + assertEqual(gc.get_count(), (2, 0, 0)) def test_collect_generations(self): - return # disable temporarily + # Avoid future allocation of method object + assertEqual = self.assertEqual gc.collect() a = dict() gc.collect(0) - self.assertEqual(gc.get_count(), (0, 1, 0)) + assertEqual(gc.get_count(), (0, 1, 0)) gc.collect(1) - self.assertEqual(gc.get_count(), (0, 0, 1)) + assertEqual(gc.get_count(), (0, 0, 1)) gc.collect(2) - self.assertEqual(gc.get_count(), (0, 0, 0)) + assertEqual(gc.get_count(), (0, 0, 0)) def test_trashcan(self): class Ouch: -- cgit v0.12