@@ -360,14 +360,14 @@ async def test_race_condition_cancel_before() -> None:
360
360
async def test_task (deadline : float , loop : asyncio .AbstractEventLoop ) -> None :
361
361
# We need the internal Timeout class to specify the deadline (not delay).
362
362
# This is needed to create the precise timing to reproduce the race condition.
363
- with Timeout (deadline , loop ):
364
- await asyncio .sleep (10 )
363
+ with pytest .warns (DeprecationWarning ):
364
+ with Timeout (deadline , loop ):
365
+ await asyncio .sleep (10 )
365
366
366
367
loop = asyncio .get_running_loop ()
367
368
deadline = loop .time () + 1
368
369
t = asyncio .create_task (test_task (deadline , loop ))
369
370
loop .call_at (deadline , t .cancel )
370
- await asyncio .sleep (1.1 )
371
371
# If we get a TimeoutError, then the code is broken.
372
372
with pytest .raises (asyncio .CancelledError ):
373
373
await t
@@ -386,14 +386,14 @@ async def test_race_condition_cancel_after() -> None:
386
386
async def test_task (deadline : float , loop : asyncio .AbstractEventLoop ) -> None :
387
387
# We need the internal Timeout class to specify the deadline (not delay).
388
388
# This is needed to create the precise timing to reproduce the race condition.
389
- with Timeout (deadline , loop ):
390
- await asyncio .sleep (10 )
389
+ with pytest .warns (DeprecationWarning ):
390
+ with Timeout (deadline , loop ):
391
+ await asyncio .sleep (10 )
391
392
392
393
loop = asyncio .get_running_loop ()
393
394
deadline = loop .time () + 1
394
395
t = asyncio .create_task (test_task (deadline , loop ))
395
- loop .call_at (deadline + 0.000001 , t .cancel )
396
- await asyncio .sleep (1.1 )
396
+ loop .call_at (deadline + 0.0000000000001 , t .cancel )
397
397
# If we get a TimeoutError, then the code is broken.
398
398
with pytest .raises (asyncio .CancelledError ):
399
399
await t
0 commit comments