summaryrefslogtreecommitdiff
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-03-31 21:32:15 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2010-03-31 21:32:15 +0000
commita57df2cf1d627840dff505e8487fbd5f42414c7b (patch)
tree87d099bca7fc01072ad6911e9ffa79707b982704 /Lib/test/test_weakref.py
parent26cc99da2a350f3093c9d7055794daef2034e2a4 (diff)
downloadcpython-git-a57df2cf1d627840dff505e8487fbd5f42414c7b.tar.gz
Issue #8268: Old-style classes (not just instances) now support weak
references.
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 536a987fe4..bc2982fadb 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -685,6 +685,26 @@ class ReferencesTestCase(TestBase):
# No exception should be raised here
gc.collect()
+ def test_classes(self):
+ # Check that both old-style classes and new-style classes
+ # are weakrefable.
+ class A(object):
+ pass
+ class B:
+ pass
+ l = []
+ weakref.ref(int)
+ a = weakref.ref(A, l.append)
+ A = None
+ gc.collect()
+ self.assertEqual(a(), None)
+ self.assertEqual(l, [a])
+ b = weakref.ref(B, l.append)
+ B = None
+ gc.collect()
+ self.assertEqual(b(), None)
+ self.assertEqual(l, [a, b])
+
class SubclassableWeakrefTestCase(TestBase):