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)
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
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
def test_repr(self): repr(tasyncio.AsyncRetrying())