[Python-checkins] python/dist/src/Lib/test test_itertools.py, 1.29, 1.30 (original) (raw)
rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sat May 8 15:49:45 EDT 2004
- Previous message: [Python-checkins] python/dist/src/Modules itertoolsmodule.c, 1.32, 1.33
- Next message: [Python-checkins] python/dist/src/Modules itertoolsmodule.c, 1.18.6.3, 1.18.6.4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2267/Lib/test
Modified Files: test_itertools.py Log Message: SF #950057: itertools.chain doesn't "process" exceptions as they occur
Both cycle() and chain() were handling exceptions only when switching input sources. The patch makes the handle more immediate.
Will backport.
Index: test_itertools.py
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** test_itertools.py 10 Feb 2004 09:25:40 -0000 1.29 --- test_itertools.py 8 May 2004 19:49:42 -0000 1.30
*** 645,648 **** --- 645,678 ----
def test_sf_950057(self):
# Make sure that chain() and cycle() catch exceptions immediately
# rather than when shifting between input sources
def gen1():
hist.append(0)
yield 1
hist.append(1)
assert False
hist.append(2)
def gen2(x):
hist.append(3)
yield 2
hist.append(4)
if x:
raise StopIteration
hist = []
self.assertRaises(AssertionError, list, chain(gen1(), gen2(False)))
self.assertEqual(hist, [0,1])
hist = []
self.assertRaises(AssertionError, list, chain(gen1(), gen2(True)))
self.assertEqual(hist, [0,1])
hist = []
self.assertRaises(AssertionError, list, cycle(gen1()))
self.assertEqual(hist, [0,1])
- libreftest = """ Doctest for examples in the library reference: libitertools.tex
- Previous message: [Python-checkins] python/dist/src/Modules itertoolsmodule.c, 1.32, 1.33
- Next message: [Python-checkins] python/dist/src/Modules itertoolsmodule.c, 1.18.6.3, 1.18.6.4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]