Ejemplo n.º 1
0
    def test_next(self):
        l1 = (x for x in range(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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    def test_iter(self):
        l1 = (x for x in range(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)
Ejemplo n.º 4
0
    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)