Back to index

python3.2  3.2.2
Public Member Functions
test.test_itertools.RegressionTests Class Reference

List of all members.

Public Member Functions

def test_sf_793826
def test_sf_950057

Detailed Description

Definition at line 1381 of file test_itertools.py.


Member Function Documentation

Definition at line 1383 of file test_itertools.py.

01383 
01384     def test_sf_793826(self):
01385         # Fix Armin Rigo's successful efforts to wreak havoc
01386 
01387         def mutatingtuple(tuple1, f, tuple2):
01388             # this builds a tuple t which is a copy of tuple1,
01389             # then calls f(t), then mutates t to be equal to tuple2
01390             # (needs len(tuple1) == len(tuple2)).
01391             def g(value, first=[1]):
01392                 if first:
01393                     del first[:]
01394                     f(next(z))
01395                 return value
01396             items = list(tuple2)
01397             items[1:1] = list(tuple1)
01398             gen = map(g, items)
01399             z = zip(*[gen]*len(tuple1))
01400             next(z)
01401 
01402         def f(t):
01403             global T
01404             T = t
01405             first[:] = list(T)
01406 
01407         first = []
01408         mutatingtuple((1,2,3), f, (4,5,6))
01409         second = list(T)
01410         self.assertEqual(first, second)
01411 

Here is the call graph for this function:

Definition at line 1412 of file test_itertools.py.

01412 
01413     def test_sf_950057(self):
01414         # Make sure that chain() and cycle() catch exceptions immediately
01415         # rather than when shifting between input sources
01416 
01417         def gen1():
01418             hist.append(0)
01419             yield 1
01420             hist.append(1)
01421             raise AssertionError
01422             hist.append(2)
01423 
01424         def gen2(x):
01425             hist.append(3)
01426             yield 2
01427             hist.append(4)
01428             if x:
01429                 raise StopIteration
01430 
01431         hist = []
01432         self.assertRaises(AssertionError, list, chain(gen1(), gen2(False)))
01433         self.assertEqual(hist, [0,1])
01434 
01435         hist = []
01436         self.assertRaises(AssertionError, list, chain(gen1(), gen2(True)))
01437         self.assertEqual(hist, [0,1])
01438 
01439         hist = []
01440         self.assertRaises(AssertionError, list, cycle(gen1()))
01441         self.assertEqual(hist, [0,1])

Here is the call graph for this function:


The documentation for this class was generated from the following file: