MCPcopy Index your code
hub / github.com/python/cpython / test_collect

Method test_collect

Lib/test/test_gc.py:1314–1341  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1312 e.partner = None
1313
1314 def test_collect(self):
1315 self.preclean()
1316 gc.collect()
1317 # Algorithmically verify the contents of self.visit
1318 # because it is long and tortuous.
1319
1320 # Count the number of visits to each callback
1321 n = [v[0] for v in self.visit]
1322 n1 = [i for i in n if i == 1]
1323 n2 = [i for i in n if i == 2]
1324 self.assertEqual(n1, [1]*2)
1325 self.assertEqual(n2, [2]*2)
1326
1327 # Count that we got the right number of start and stop callbacks.
1328 n = [v[1] for v in self.visit]
1329 n1 = [i for i in n if i == "start"]
1330 n2 = [i for i in n if i == "stop"]
1331 self.assertEqual(n1, ["start"]*2)
1332 self.assertEqual(n2, ["stop"]*2)
1333
1334 # Check that we got the right info dict for all callbacks
1335 for v in self.visit:
1336 info = v[2]
1337 self.assertIn("generation", info)
1338 self.assertIn("collected", info)
1339 self.assertIn("uncollectable", info)
1340 self.assertIn("candidates", info)
1341 self.assertIn("duration", info)
1342
1343 def test_collect_generation(self):
1344 self.preclean()

Callers

nothing calls this directly

Calls 4

precleanMethod · 0.95
assertInMethod · 0.80
collectMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected