mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Fix and test weak referencing of itertools.tee objects.
This commit is contained in:
parent
837dd93e3b
commit
a9f6092904
2 changed files with 14 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
import unittest
|
||||
from test import test_support
|
||||
from itertools import *
|
||||
from weakref import proxy
|
||||
import sys
|
||||
import operator
|
||||
import random
|
||||
|
@ -382,6 +383,13 @@ class TestBasicOps(unittest.TestCase):
|
|||
t3 = tnew(t1)
|
||||
self.assert_(list(t1) == list(t2) == list(t3) == list('abc'))
|
||||
|
||||
# test that tee objects are weak referencable
|
||||
a, b = tee(xrange(10))
|
||||
p = proxy(a)
|
||||
self.assertEqual(getattr(p, '__class__'), type(b))
|
||||
del a
|
||||
self.assertRaises(ReferenceError, getattr, p, '__class__')
|
||||
|
||||
def test_StopIteration(self):
|
||||
self.assertRaises(StopIteration, izip().next)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue