Replace asyncio.async() by asyncio.ensure_future() in tests. Ref #2566.

This commit is contained in:
grossmj
2018-08-24 18:52:15 +07:00
parent 089d25c79d
commit a3d1e865a8
19 changed files with 171 additions and 171 deletions

View File

@ -43,7 +43,7 @@ def manager(port_manager):
@pytest.fixture(scope="function")
def node(project, manager, loop):
node = manager.create_node("test", project.id, "00010203-0405-0607-0809-0a0b0c0d0e0f")
return loop.run_until_complete(asyncio.async(node))
return loop.run_until_complete(asyncio.ensure_future(node))
def test_affect_uuid():
@ -140,7 +140,7 @@ def test_project_delete(loop):
project = Project(project_id=str(uuid4()))
directory = project.path
assert os.path.exists(directory)
loop.run_until_complete(asyncio.async(project.delete()))
loop.run_until_complete(asyncio.ensure_future(project.delete()))
assert os.path.exists(directory) is False
@ -150,7 +150,7 @@ def test_project_delete_permission_issue(loop):
assert os.path.exists(directory)
os.chmod(directory, 0)
with pytest.raises(aiohttp.web.HTTPInternalServerError):
loop.run_until_complete(asyncio.async(project.delete()))
loop.run_until_complete(asyncio.ensure_future(project.delete()))
os.chmod(directory, 700)
@ -164,7 +164,7 @@ def test_project_add_node(manager):
def test_project_close(loop, node, project):
with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM.close") as mock:
loop.run_until_complete(asyncio.async(project.close()))
loop.run_until_complete(asyncio.ensure_future(project.close()))
assert mock.called
assert node.id not in node.manager._nodes
@ -181,7 +181,7 @@ def test_list_files(tmpdir, loop):
with open(os.path.join(path, "test.txt"), "w+") as f:
f.write("test2")
files = loop.run_until_complete(asyncio.async(project.list_files()))
files = loop.run_until_complete(asyncio.ensure_future(project.list_files()))
assert files == [
{
@ -210,5 +210,5 @@ def test_emit(async_run):
def test_update_project(loop):
variables = [{"name": "TEST", "value": "VAL"}]
project = Project(project_id=str(uuid.uuid4()))
loop.run_until_complete(asyncio.async(project.update(variables=variables)))
loop.run_until_complete(asyncio.ensure_future(project.update(variables=variables)))
assert project.variables == variables