mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Make sets and deques weak referencable.
This commit is contained in:
parent
d70ad8a9d9
commit
691d80532b
5 changed files with 32 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
from collections import deque
|
||||
import unittest
|
||||
from test import test_support
|
||||
from weakref import proxy
|
||||
import copy
|
||||
import cPickle as pickle
|
||||
from cStringIO import StringIO
|
||||
|
@ -435,6 +436,12 @@ class TestSubclass(unittest.TestCase):
|
|||
self.assertEqual(type(d), type(e))
|
||||
self.assertEqual(list(d), list(e))
|
||||
|
||||
def test_weakref(self):
|
||||
d = deque('gallahad')
|
||||
p = proxy(d)
|
||||
self.assertEqual(str(p), str(d))
|
||||
d = None
|
||||
self.assertRaises(ReferenceError, str, p)
|
||||
|
||||
#==============================================================================
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue