Skip to content

Commit b562f95

Browse files
committed
Fix unstable test
1 parent cceda6a commit b562f95

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
11
repos:
2-
- repo: local
3-
hooks:
4-
- id: gen-cli-docs
5-
name: Generate CLI docs
6-
language: system
7-
entry: make docs
8-
pass_filenames: false
9-
- repo: local
10-
hooks:
11-
- id: check-mixin-classes
12-
name: Validate mixins classes
13-
language: system
14-
entry: make check-mixins
15-
pass_filenames: false
162
- repo: https://github.com/pre-commit/pre-commit-hooks
173
rev: 'v4.0.1'
184
hooks:

tests/test_timeout.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,14 @@ async def test_race_condition_cancel_before() -> None:
360360
async def test_task(deadline: float, loop: asyncio.AbstractEventLoop) -> None:
361361
# We need the internal Timeout class to specify the deadline (not delay).
362362
# 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)
365366

366367
loop = asyncio.get_running_loop()
367368
deadline = loop.time() + 1
368369
t = asyncio.create_task(test_task(deadline, loop))
369370
loop.call_at(deadline, t.cancel)
370-
await asyncio.sleep(1.1)
371371
# If we get a TimeoutError, then the code is broken.
372372
with pytest.raises(asyncio.CancelledError):
373373
await t
@@ -386,14 +386,14 @@ async def test_race_condition_cancel_after() -> None:
386386
async def test_task(deadline: float, loop: asyncio.AbstractEventLoop) -> None:
387387
# We need the internal Timeout class to specify the deadline (not delay).
388388
# 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)
391392

392393
loop = asyncio.get_running_loop()
393394
deadline = loop.time() + 1
394395
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)
397397
# If we get a TimeoutError, then the code is broken.
398398
with pytest.raises(asyncio.CancelledError):
399399
await t

0 commit comments

Comments
 (0)