Пример #1
0
    async def test_zip_longest_exception(self):
        async def gen():
            yield 1
            yield 2
            raise Exception("fake error")

        a = gen()
        b = ait.repeat(5)

        it = ait.zip_longest(a, b)

        for k in [(1, 5), (2, 5)]:
            self.assertEqual(await ait.next(it), k)
        with self.assertRaisesRegex(Exception, "fake error"):
            await ait.next(it)
Пример #2
0
 async def test_repeat_limit(self):
     it = ait.repeat(42, 5)
     for k in [42] * 5:
         self.assertEqual(await ait.next(it), k)
     with self.assertRaises(StopAsyncIteration):
         await ait.next(it)
Пример #3
0
 async def test_repeat(self):
     it = ait.repeat(42)
     for k in [42] * 10:
         self.assertEqual(await ait.next(it), k)