Skip to content

Commit

Permalink
Reduce reliance on timing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Booth committed Feb 4, 2021
1 parent 8d38b47 commit 711d5e7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/test_curio.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async def test_tg_spawn():

@pytest.mark.asyncio
async def test_tg_cancel_remaining():
tasks = [await spawn(sleep, x/200) for x in range(1, 4)]
tasks = [await spawn(sleep, x/50) for x in range(1, 4)]
t = TaskGroup(tasks)
assert await t.next_done()
await t.cancel_remaining()
Expand Down Expand Up @@ -196,7 +196,7 @@ async def test_tg_cm_object():

tasks = [await spawn(return_value(None, 0.01)),
await spawn(return_value(4, 0.02)),
await spawn(return_value(2, 0.03))]
await spawn(return_value(2, 0.1))]
async with TaskGroup(tasks, wait=object) as t:
pass
assert tasks[0].result() == None
Expand Down Expand Up @@ -370,10 +370,10 @@ async def t1(*values):
@pytest.mark.asyncio
async def test_timeout_after_no_expire():
async def t1(*values):
return await return_after_sleep(1 + sum(values), 0.01)
return await return_after_sleep(1 + sum(values), 0.005)

try:
assert await timeout_after(0.02, t1, 1) == 2
assert await timeout_after(0.04, t1, 1) == 2
except TaskTimeout:
assert False
await sleep(0.02)
Expand Down Expand Up @@ -733,7 +733,7 @@ async def test_ignore_after_no_expire():
async def t1(*values):
return await return_after_sleep(1 + sum(values), 0.001)

assert await ignore_after(0.005, t1, 1) == 2
assert await ignore_after(0.02, t1, 1) == 2
await sleep(0.002)


Expand Down

0 comments on commit 711d5e7

Please sign in to comment.