MCPcopy Index your code
hub / github.com/python/cpython / test_sf_950057

Method test_sf_950057

Lib/test/test_itertools.py:2431–2457  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2429
2430
2431 def test_sf_950057(self):
2432 # Make sure that chain() and cycle() catch exceptions immediately
2433 # rather than when shifting between input sources
2434
2435 def gen1():
2436 hist.append(0)
2437 yield 1
2438 hist.append(1)
2439 raise AssertionError
2440 hist.append(2)
2441
2442 def gen2(x):
2443 hist.append(3)
2444 yield 2
2445 hist.append(4)
2446
2447 hist = []
2448 self.assertRaises(AssertionError, list, chain(gen1(), gen2(False)))
2449 self.assertEqual(hist, [0,1])
2450
2451 hist = []
2452 self.assertRaises(AssertionError, list, chain(gen1(), gen2(True)))
2453 self.assertEqual(hist, [0,1])
2454
2455 hist = []
2456 self.assertRaises(AssertionError, list, cycle(gen1()))
2457 self.assertEqual(hist, [0,1])
2458
2459 @support.skip_if_pgo_task
2460 @support.requires_resource('cpu')

Callers

nothing calls this directly

Calls 3

chainFunction · 0.85
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected