summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_gc.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-02-15 22:44:20 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-02-15 22:44:20 (GMT)
commitd8bcbf2b2ecca3cf168718d50dc46ba5775b0bc9 (patch)
tree589edc7b5f997ab5e285255aa6e36bc947a02efd /Lib/test/test_gc.py
parentf05fa33a6c42bc21ffdfe7a20226a2b9a83ac3c2 (diff)
downloadcpython-d8bcbf2b2ecca3cf168718d50dc46ba5775b0bc9.zip
cpython-d8bcbf2b2ecca3cf168718d50dc46ba5775b0bc9.tar.gz
cpython-d8bcbf2b2ecca3cf168718d50dc46ba5775b0bc9.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_gc.py')
-rw-r--r--Lib/test/test_gc.py24
1 files 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: