diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-04-08 19:44:13 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-04-08 19:44:13 (GMT) |
commit | 8805e66ec8c67a8ec2ce6e1e6e6802ce2252925b (patch) | |
tree | 96d366dd9aacb626208ea0ce75eee5211f2b041b /Lib/test/test_gc.py | |
parent | fb2a6ccfc42cb15e15c4d2608bf096357a8a79ed (diff) | |
download | cpython-8805e66ec8c67a8ec2ce6e1e6e6802ce2252925b.zip cpython-8805e66ec8c67a8ec2ce6e1e6e6802ce2252925b.tar.gz cpython-8805e66ec8c67a8ec2ce6e1e6e6802ce2252925b.tar.bz2 |
New tests identical to boom and boom2, except using new-style classes.
These never failed in 2.3, and the tests confirm it. They still blow up
in the 2.2 branch, despite that all the gc-vs-__del__ fixes from 2.3
have been backported (and this is expected -- 2.2 needs more work than
2.3 needed).
Diffstat (limited to 'Lib/test/test_gc.py')
-rw-r--r-- | Lib/test/test_gc.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 0f99ef8..50df818 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -304,6 +304,48 @@ def test_boom2(): expect(gc.collect(), 4, "boom2") expect(len(gc.garbage), garbagelen, "boom2") +# boom__new and boom2_new are exactly like boom and boom2, except use +# new-style classes. + +class Boom_New(object): + def __getattr__(self, someattribute): + del self.attr + raise AttributeError + +def test_boom_new(): + a = Boom_New() + b = Boom_New() + a.attr = b + b.attr = a + + gc.collect() + garbagelen = len(gc.garbage) + del a, b + expect(gc.collect(), 4, "boom_new") + expect(len(gc.garbage), garbagelen, "boom_new") + +class Boom2_New(object): + def __init__(self): + self.x = 0 + + def __getattr__(self, someattribute): + self.x += 1 + if self.x > 1: + del self.attr + raise AttributeError + +def test_boom2_new(): + a = Boom2_New() + b = Boom2_New() + a.attr = b + b.attr = a + + gc.collect() + garbagelen = len(gc.garbage) + del a, b + expect(gc.collect(), 4, "boom2_new") + expect(len(gc.garbage), garbagelen, "boom2_new") + def test_get_referents(): alist = [1, 3, 5] got = gc.get_referents(alist) @@ -347,6 +389,8 @@ def test_all(): run_test("trashcan", test_trashcan) run_test("boom", test_boom) run_test("boom2", test_boom2) + run_test("boom_new", test_boom_new) + run_test("boom2_new", test_boom2_new) run_test("get_referents", test_get_referents) def test(): |