Exemplo n.º 1
0
    async def test_dropwhile_coroutine_list(self):
        async def pred(x):
            return x < 2

        it = ait.dropwhile(pred, srange)
        for k in [2, 3]:
            self.assertEqual(await ait.next(it), k)
        with self.assertRaises(StopAsyncIteration):
            await ait.next(it)
Exemplo n.º 2
0
    async def test_dropwhile_coroutine_gen(self):
        async def pred(x):
            return x < 2

        async def gen():
            yield 1
            yield 2
            yield 42

        it = ait.dropwhile(pred, gen())
        for k in [2, 42]:
            self.assertEqual(await ait.next(it), k)
        with self.assertRaises(StopAsyncIteration):
            await ait.next(it)
Exemplo n.º 3
0
    async def test_dropwhile_empty(self):
        def pred(x):
            return x < 2

        result = await ait.list(ait.dropwhile(pred, []))
        self.assertEqual(result, [])