def test_next(self): l1 = (x for x in compat.xrange(3)) l2 = iter([3, 4, 5]) l3 = iter([6]) l4 = iter([7, 8]) chain = IteratorChain(l1, l2, l3) for irun in range(9): element = next(chain) self.assertEqual(irun, element) if irun == 4: chain.add(l4)
def test_next(self): l1 = (x for x in compat.xrange(3)) l2 = iter([3,4,5]) l3 = iter([6]) l4 = iter([7,8]) chain = IteratorChain(l1, l2, l3) for irun in range(9): element = next(chain) self.assertEqual(irun, element) if irun == 4: chain.add(l4)
def test_iter(self): l1 = (x for x in compat.xrange(3)) l2 = iter([3, 4, 5]) l3 = iter([6]) l4 = iter([7, 8]) chain = IteratorChain(l1, l2, l3) count = 0 elem_list = [] for elem in chain: self.assertEqual(elem, count) count += 1 elem_list.append(elem) if count == 3: chain.add(l4) self.assertEqual(len(elem_list), 9)
def test_iter(self): l1 = (x for x in compat.xrange(3)) l2 = iter([3,4,5]) l3 = iter([6]) l4 = iter([7,8]) chain = IteratorChain(l1, l2, l3) count = 0 elem_list = [] for elem in chain: self.assertEqual(elem, count) count += 1 elem_list.append(elem) if count == 3: chain.add(l4) self.assertEqual(len(elem_list), 9)