Example #1
0
    async def test_permutations_gen(self):
        async def gen():
            yield 1
            yield 2
            yield 3

        it = ait.permutations(gen(), r=2)
        for k in [(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)]:
            self.assertEqual(await ait.next(it), k)
        with self.assertRaises(StopAsyncIteration):
            await ait.next(it)
Example #2
0
 async def test_permutations_list(self):
     it = ait.permutations(srange, r=2)
     for k in [(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)]:
         self.assertEqual(await ait.next(it), k)
     with self.assertRaises(StopAsyncIteration):
         await ait.next(it)