diff options
Diffstat (limited to 'Lib/test/test_deque.py')
-rw-r--r-- | Lib/test/test_deque.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py index 7af0803..27c89c4 100644 --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -1,7 +1,8 @@ from collections import deque import unittest from test import support, seq_tests -from weakref import proxy +import gc +import weakref import copy import pickle from io import StringIO @@ -420,6 +421,22 @@ class TestBasic(unittest.TestCase): d.append(1) gc.collect() + def test_container_iterator(self): + # Bug #3680: tp_traverse was not implemented for deque iterator objects + class C(object): + pass + for i in range(2): + obj = C() + ref = weakref.ref(obj) + if i == 0: + container = deque([obj, 1]) + else: + container = reversed(deque([obj, 1])) + obj.x = iter(container) + del obj, container + gc.collect() + self.assert_(ref() is None, "Cycle was not collected") + class TestVariousIteratorArgs(unittest.TestCase): def test_constructor(self): @@ -530,7 +547,7 @@ class TestSubclass(unittest.TestCase): def test_weakref(self): d = deque('gallahad') - p = proxy(d) + p = weakref.proxy(d) self.assertEqual(str(p), str(d)) d = None self.assertRaises(ReferenceError, str, p) |