diff options
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 92304b4..141d791 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1,8 +1,10 @@ import builtins +import gc import sys import types import math import unittest +import weakref from copy import deepcopy from test import support @@ -1186,7 +1188,6 @@ order (MRO) for bases """ self.assertEqual(Counted.counter, 0) # Test lookup leaks [SF bug 572567] - import gc if hasattr(gc, 'get_objects'): class G(object): def __eq__(self, other): @@ -4380,7 +4381,6 @@ order (MRO) for bases """ self.assertRaises(AttributeError, getattr, C(), "attr") self.assertEqual(descr.counter, 4) - import gc class EvilGetattribute(object): # This used to segfault def __getattr__(self, name): @@ -4393,6 +4393,9 @@ order (MRO) for bases """ self.assertRaises(AttributeError, getattr, EvilGetattribute(), "attr") + def test_type___getattribute__(self): + self.assertRaises(TypeError, type.__getattribute__, list, type) + def test_abstractmethods(self): # type pretends not to have __abstractmethods__. self.assertRaises(AttributeError, getattr, type, "__abstractmethods__") @@ -4429,6 +4432,21 @@ order (MRO) for bases """ foo = Foo() str(foo) + def test_cycle_through_dict(self): + # See bug #1469629 + class X(dict): + def __init__(self): + dict.__init__(self) + self.__dict__ = self + x = X() + x.attr = 42 + wr = weakref.ref(x) + del x + support.gc_collect() + self.assertIsNone(wr()) + for o in gc.get_objects(): + self.assertIsNot(type(o), X) + class DictProxyTests(unittest.TestCase): def setUp(self): class C(object): |