Minor improvements to itertools.tee():

* tee object is no longer subclassable
* independent iterators renamed to "itertools.tee_iterator"
* fixed doc string typo and added entry in the module doc string
This commit is contained in:
Raymond Hettinger 2003-10-26 14:25:56 +00:00
parent 397b45d4ba
commit f0c5aec85f
2 changed files with 21 additions and 9 deletions

View file

@ -243,6 +243,18 @@ class TestBasicOps(unittest.TestCase):
self.assertRaises(TypeError, tee, 3)
self.assertRaises(TypeError, tee, [1,2], 'x')
try:
class A(tee): pass
except TypeError:
pass
else:
self.fail("tee constructor should not be subclassable")
# tee_iterator should not be instantiable
a, b = tee(xrange(10))
self.assertRaises(TypeError, type(a))
self.assert_(a is iter(a)) # tee_iterator should support __iter__
def test_StopIteration(self):
self.assertRaises(StopIteration, izip().next)