async def test_amap(self, max_per_second: float) -> None:
     with self.assert_limit(max_per_second) as spy:
         async with aiometer.amap(spy.task,
                                  spy.args,
                                  max_per_second=max_per_second) as results:
             async for _ in results:
                 pass  # pragma: no cover  # Python 3.7 fix.
 async def test_amap(self, max_at_once: int) -> None:
     with self.assert_limit(max_at_once) as spy:
         async with aiometer.amap(spy.async_fn,
                                  spy.args,
                                  max_at_once=max_at_once) as results:
             async for _ in results:
                 pass  # pragma: no cover  # Python 3.7 fix.
    async def test_amap(self) -> None:
        async def process(item: str) -> str:
            return item.capitalize()

        items = ["apple", "banana", "cherry", "apple"]
        async with aiometer.amap(process, items) as results:
            output = {result async for result in results}

        assert output == {"Apple", "Banana", "Cherry"}
    async def test_amap_ignore_results(self) -> None:
        called = 0

        async def process(item: str) -> None:
            nonlocal called
            called += 1

        items = ["apple", "banana", "cherry", "apple"]
        async with aiometer.amap(process, items):
            pass

        # Should have waited for all tasks to complete before exiting.
        assert called == 4
    async def test_amap_task_exception(self) -> None:
        class Failure(Exception):
            pass

        async def process(item: str) -> str:
            if item == "fail":
                raise Failure
            return item

        items = ["apple", "banana", "fail", "apple"]
        with pytest.raises(Failure):
            async with aiometer.amap(process, items) as results:
                async for result in results:
                    pass  # pragma: no cover  # Python 3.7 fix.