コード例 #1
0
ファイル: test_asyncio.py プロジェクト: NatureGeorge/tenacity
 async def test_sleeps(self):
     start = current_time_ms()
     try:
         async for attempt in tasyncio.AsyncRetrying(
                 stop=stop_after_attempt(1), wait=wait_fixed(1)):
             with attempt:
                 raise Exception()
     except RetryError:
         pass
     t = current_time_ms() - start
     self.assertLess(t, 1.1)
コード例 #2
0
ファイル: test_asyncio.py プロジェクト: NatureGeorge/tenacity
    async def test_do_max_attempts(self):
        attempts = 0
        retrying = tasyncio.AsyncRetrying(stop=stop_after_attempt(3))
        try:
            async for attempt in retrying:
                with attempt:
                    attempts += 1
                    raise Exception
        except RetryError:
            pass

        assert attempts == 3
コード例 #3
0
ファイル: test_asyncio.py プロジェクト: NatureGeorge/tenacity
    async def test_reraise(self):
        class CustomError(Exception):
            pass

        try:
            async for attempt in tasyncio.AsyncRetrying(
                    stop=stop_after_attempt(1), reraise=True):
                with attempt:
                    raise CustomError()
        except CustomError:
            pass
        else:
            raise Exception
コード例 #4
0
ファイル: test_asyncio.py プロジェクト: NatureGeorge/tenacity
 def test_repr(self):
     repr(tasyncio.AsyncRetrying())