diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2003-04-04 20:00:04 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2003-04-04 20:00:04 (GMT) |
commit | dee38ac7ddea4268156948062aaa2e1cabc7e5aa (patch) | |
tree | 38c9c7df0d18a1382730b04784f97a331fad1459 | |
parent | ce136e985a9a3f5525e01f6a00041841e06a1bd7 (diff) | |
download | cpython-dee38ac7ddea4268156948062aaa2e1cabc7e5aa.zip cpython-dee38ac7ddea4268156948062aaa2e1cabc7e5aa.tar.gz cpython-dee38ac7ddea4268156948062aaa2e1cabc7e5aa.tar.bz2 |
Add Tim's gc boom test to the test suite.
-rw-r--r-- | Lib/test/test_gc.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 95cea29..f190fa4 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -253,6 +253,24 @@ def test_trashcan(): v = {1: v, 2: Ouch()} gc.disable() +class C: + def __getattr__(self, attr): + del self.attr + raise AttributeError + +def test_boom(): + a = C() + b = C() + a.attr = b + b.attr = a + + gc.collect() + del a, b + # the collection will invoke the getattr and decref one of the + # object. so they are deallocated without being reported as + # part of a cycle. + expect(gc.collect(), 0, "boom") + def test_all(): gc.collect() # Delete 2nd generation garbage run_test("lists", test_list) @@ -271,6 +289,7 @@ def test_all(): run_test("__del__ (new class)", test_del_newclass) run_test("saveall", test_saveall) run_test("trashcan", test_trashcan) + run_test("boom", test_boom) def test(): if verbose: |