summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-03-31 21:40:47 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-03-31 21:40:47 (GMT)
commit3af01a15790d5750004acb07ce7ab335aa489699 (patch)
treeec72061b44ff45f38820c00f6285856576d28fad /Lib/test/test_weakref.py
parentd5f9bf5ecfcab58605d8070b285b47ffb18b99a2 (diff)
downloadcpython-3af01a15790d5750004acb07ce7ab335aa489699.zip
cpython-3af01a15790d5750004acb07ce7ab335aa489699.tar.gz
cpython-3af01a15790d5750004acb07ce7ab335aa489699.tar.bz2
NOTE: only ported the test for new-style classes.
Merged revisions 79535 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r79535 | antoine.pitrou | 2010-03-31 23:32:15 +0200 (mer., 31 mars 2010) | 5 lines 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.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index a909428..8b5bbc3 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -680,6 +680,18 @@ class ReferencesTestCase(TestBase):
# No exception should be raised here
gc.collect()
+ def test_classes(self):
+ # Check that classes are weakrefable.
+ class A(object):
+ pass
+ l = []
+ weakref.ref(int)
+ a = weakref.ref(A, l.append)
+ A = None
+ gc.collect()
+ self.assertEqual(a(), None)
+ self.assertEqual(l, [a])
+
class SubclassableWeakrefTestCase(TestBase):