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

@ -56,7 +56,7 @@ def test_vm_invalid_traceng_path(vm, manager, loop):
with pytest.raises(TraceNGError):
nio = manager.create_nio({"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
vm.port_add_nio_binding(0, nio)
loop.run_until_complete(asyncio.async(vm.start()))
loop.run_until_complete(asyncio.ensure_future(vm.start()))
assert vm.name == "test"
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0e"
@ -72,7 +72,7 @@ def test_start(loop, vm, async_run):
with patch("sys.platform", return_value="win"):
with asyncio_patch("gns3server.compute.traceng.traceng_vm.TraceNGVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process) as mock_exec:
loop.run_until_complete(asyncio.async(vm.start("192.168.1.2")))
loop.run_until_complete(asyncio.ensure_future(vm.start("192.168.1.2")))
assert mock_exec.call_args[0] == (vm._traceng_path(),
'-u',
'-c',
@ -115,7 +115,7 @@ def test_stop(loop, vm, async_run):
assert vm.is_running()
with asyncio_patch("gns3server.utils.asyncio.wait_for_process_termination"):
loop.run_until_complete(asyncio.async(vm.stop()))
loop.run_until_complete(asyncio.ensure_future(vm.stop()))
assert vm.is_running() is False
process.terminate.assert_called_with()
@ -175,5 +175,5 @@ def test_close(vm, port_manager, loop):
with asyncio_patch("gns3server.compute.traceng.traceng_vm.TraceNGVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
vm.start()
loop.run_until_complete(asyncio.async(vm.close()))
loop.run_until_complete(asyncio.ensure_future(vm.close()))
assert vm.is_running() is False