def test_timeout_time(loop):
foo_running = None
start = loop.time()
with pytest.raises(asyncio.TimeoutError):
with timeout(0.1, loop=loop):
foo_running = True
try:
yield from asyncio.sleep(0.2, loop=loop)
finally:
foo_running = False
dt = loop.time() - start
if not (0.09 < dt < 0.11) and os.environ.get('APPVEYOR'):
pytest.xfail('appveyor sometimes is toooo sloooow')
assert 0.09 < dt < 0.11
assert not foo_running
评论列表
文章目录