diff --git a/dev-requirements.txt b/dev-requirements.txt index b926d113..86cc066f 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -4,7 +4,5 @@ pytest==7.0.1; python_version < '3.7' # last version to support Python 3.6 pytest==7.1.2; python_version >= '3.7' flake8==5.0.4 pytest-timeout==2.1.0 -pytest-asyncio==0.16.0; python_version < '3.7' # last version to support Python 3.6 -pytest-asyncio==0.19.0; python_version >= '3.7' pytest-aiohttp==0.3.0; python_version < '3.7' # last version to support Python 3.6 pytest-aiohttp==1.0.4; python_version >= '3.7' diff --git a/tests/compute/builtin/nodes/test_cloud.py b/tests/compute/builtin/nodes/test_cloud.py index 7cafef31..09506b45 100644 --- a/tests/compute/builtin/nodes/test_cloud.py +++ b/tests/compute/builtin/nodes/test_cloud.py @@ -17,7 +17,6 @@ import uuid import pytest -import pytest_asyncio from unittest.mock import MagicMock, patch, call from gns3server.compute.builtin.nodes.cloud import Cloud @@ -31,7 +30,7 @@ def nio(): return NIOUDP(4242, "127.0.0.1", 4343) -@pytest_asyncio.fixture +@pytest.fixture async def manager(): m = MagicMock() diff --git a/tests/compute/docker/test_docker.py b/tests/compute/docker/test_docker.py index 94a2d941..60e2d73e 100644 --- a/tests/compute/docker/test_docker.py +++ b/tests/compute/docker/test_docker.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio from unittest.mock import MagicMock, patch from tests.utils import asyncio_patch, AsyncioMagicMock @@ -24,7 +23,7 @@ from gns3server.compute.docker import Docker, DOCKER_PREFERRED_API_VERSION, DOCK from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error -@pytest_asyncio.fixture +@pytest.fixture async def vm(): vm = Docker() diff --git a/tests/compute/dynamips/test_dynamips_manager.py b/tests/compute/dynamips/test_dynamips_manager.py index e1b8585f..11bbdfc0 100644 --- a/tests/compute/dynamips/test_dynamips_manager.py +++ b/tests/compute/dynamips/test_dynamips_manager.py @@ -17,7 +17,6 @@ import pytest -import pytest_asyncio import tempfile import sys import uuid @@ -29,7 +28,7 @@ from unittest.mock import patch from tests.utils import asyncio_patch, AsyncioMagicMock -@pytest_asyncio.fixture +@pytest.fixture async def manager(port_manager): m = Dynamips.instance() diff --git a/tests/compute/dynamips/test_dynamips_router.py b/tests/compute/dynamips/test_dynamips_router.py index 6aa5f33a..1f3d0a21 100644 --- a/tests/compute/dynamips/test_dynamips_router.py +++ b/tests/compute/dynamips/test_dynamips_router.py @@ -18,7 +18,6 @@ import os import uuid import pytest -import pytest_asyncio from gns3server.compute.dynamips.nodes.router import Router from gns3server.compute.dynamips.dynamips_error import DynamipsError @@ -26,7 +25,7 @@ from gns3server.compute.dynamips import Dynamips from gns3server.config import Config -@pytest_asyncio.fixture +@pytest.fixture async def manager(port_manager): m = Dynamips.instance() diff --git a/tests/compute/iou/test_iou_vm.py b/tests/compute/iou/test_iou_vm.py index d5fe9912..79bb3489 100644 --- a/tests/compute/iou/test_iou_vm.py +++ b/tests/compute/iou/test_iou_vm.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio import asyncio import os import stat @@ -37,7 +36,7 @@ if not sys.platform.startswith("win"): from gns3server.compute.iou import IOU -@pytest_asyncio.fixture +@pytest.fixture async def manager(port_manager): m = IOU.instance() diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py index bd7fa873..af329d6e 100644 --- a/tests/compute/qemu/test_qemu_vm.py +++ b/tests/compute/qemu/test_qemu_vm.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio import asyncio import os import sys @@ -34,7 +33,7 @@ from gns3server.utils import force_unix_path, macaddress_to_int, int_to_macaddre from gns3server.compute.notification_manager import NotificationManager -@pytest_asyncio.fixture +@pytest.fixture async def manager(port_manager): m = Qemu.instance() diff --git a/tests/compute/test_base_node.py b/tests/compute/test_base_node.py index dab1a17c..50060e3a 100644 --- a/tests/compute/test_base_node.py +++ b/tests/compute/test_base_node.py @@ -18,7 +18,6 @@ from collections import OrderedDict import pytest -import pytest_asyncio from tests.utils import asyncio_patch, AsyncioMagicMock @@ -29,7 +28,7 @@ from gns3server.compute.vpcs import VPCS from gns3server.compute.nios.nio_udp import NIOUDP -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def manager(port_manager): m = VPCS.instance() diff --git a/tests/compute/traceng/test_traceng_vm.py b/tests/compute/traceng/test_traceng_vm.py index 84604976..ce36a347 100644 --- a/tests/compute/traceng/test_traceng_vm.py +++ b/tests/compute/traceng/test_traceng_vm.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio import asyncio from tests.utils import asyncio_patch, AsyncioMagicMock @@ -28,7 +27,7 @@ from gns3server.compute.traceng import TraceNG from gns3server.compute.notification_manager import NotificationManager -@pytest_asyncio.fixture +@pytest.fixture async def manager(port_manager): m = TraceNG.instance() @@ -36,7 +35,7 @@ async def manager(port_manager): return m -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def vm(compute_project, manager, ubridge_path): vm = TraceNGVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager) diff --git a/tests/compute/virtualbox/test_virtualbox_manager.py b/tests/compute/virtualbox/test_virtualbox_manager.py index 4cc00971..ddbb28b9 100644 --- a/tests/compute/virtualbox/test_virtualbox_manager.py +++ b/tests/compute/virtualbox/test_virtualbox_manager.py @@ -17,7 +17,6 @@ import pytest -import pytest_asyncio import tempfile import os import stat @@ -29,7 +28,7 @@ from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError from tests.utils import asyncio_patch -@pytest_asyncio.fixture +@pytest.fixture async def manager(port_manager): m = VirtualBox.instance() diff --git a/tests/compute/virtualbox/test_virtualbox_vm.py b/tests/compute/virtualbox/test_virtualbox_vm.py index 03ebd223..766f0215 100644 --- a/tests/compute/virtualbox/test_virtualbox_vm.py +++ b/tests/compute/virtualbox/test_virtualbox_vm.py @@ -17,7 +17,6 @@ import os import pytest -import pytest_asyncio from tests.utils import asyncio_patch, AsyncioMagicMock from gns3server.compute.virtualbox.virtualbox_vm import VirtualBoxVM @@ -25,7 +24,7 @@ from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError from gns3server.compute.virtualbox import VirtualBox -@pytest_asyncio.fixture +@pytest.fixture async def manager(port_manager): m = VirtualBox.instance() diff --git a/tests/compute/vmware/test_vmware_manager.py b/tests/compute/vmware/test_vmware_manager.py index 7f2c2e0b..336ede54 100644 --- a/tests/compute/vmware/test_vmware_manager.py +++ b/tests/compute/vmware/test_vmware_manager.py @@ -15,13 +15,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - -import pytest_asyncio +import pytest from gns3server.compute.vmware import VMware -@pytest_asyncio.fixture +@pytest.fixture async def manager(port_manager): m = VMware.instance() diff --git a/tests/compute/vmware/test_vmware_vm.py b/tests/compute/vmware/test_vmware_vm.py index bcfbefaa..2b34afa7 100644 --- a/tests/compute/vmware/test_vmware_vm.py +++ b/tests/compute/vmware/test_vmware_vm.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio from gns3server.compute.vmware.vmware_vm import VMwareVM from gns3server.compute.vmware import VMware diff --git a/tests/compute/vpcs/test_vpcs_vm.py b/tests/compute/vpcs/test_vpcs_vm.py index eda0c299..cff3bf4f 100644 --- a/tests/compute/vpcs/test_vpcs_vm.py +++ b/tests/compute/vpcs/test_vpcs_vm.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio import asyncio import os import sys @@ -31,7 +30,7 @@ from gns3server.compute.vpcs import VPCS from gns3server.compute.notification_manager import NotificationManager -@pytest_asyncio.fixture +@pytest.fixture async def manager(port_manager): m = VPCS.instance() diff --git a/tests/conftest.py b/tests/conftest.py index b04309d2..034604dd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,4 @@ import pytest -import pytest_asyncio import asyncio import tempfile import shutil @@ -35,7 +34,7 @@ if sys.platform.startswith("win"): asyncio.set_event_loop(None) -@pytest_asyncio.fixture(scope='function') +@pytest.fixture(scope='function') async def http_client(aiohttp_client): app = web.Application() @@ -72,7 +71,7 @@ def compute(controller): return compute -@pytest_asyncio.fixture +@pytest.fixture async def project(tmpdir, controller): return await controller.add_project(name="Test") diff --git a/tests/controller/gns3vm/test_virtualbox_gns3_vm.py b/tests/controller/gns3vm/test_virtualbox_gns3_vm.py index ff899c5b..31f6d738 100644 --- a/tests/controller/gns3vm/test_virtualbox_gns3_vm.py +++ b/tests/controller/gns3vm/test_virtualbox_gns3_vm.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest_asyncio +import pytest from tests.utils import asyncio_patch, AsyncioMagicMock from gns3server.utils.asyncio import wait_run_in_executor @@ -24,7 +24,7 @@ from unittest.mock import patch from gns3server.controller.gns3vm.virtualbox_gns3_vm import VirtualBoxGNS3VM -@pytest_asyncio.fixture +@pytest.fixture async def gns3vm(controller): vm = VirtualBoxGNS3VM(controller) diff --git a/tests/controller/gns3vm/test_vmware_gns3_vm.py b/tests/controller/gns3vm/test_vmware_gns3_vm.py index bf48f199..9b256e31 100644 --- a/tests/controller/gns3vm/test_vmware_gns3_vm.py +++ b/tests/controller/gns3vm/test_vmware_gns3_vm.py @@ -16,12 +16,11 @@ # along with this program. If not, see . import pytest -import pytest_asyncio from gns3server.controller.gns3vm.vmware_gns3_vm import VMwareGNS3VM -@pytest_asyncio.fixture +@pytest.fixture async def gns3vm(controller): vm = VMwareGNS3VM(controller) diff --git a/tests/controller/test_export_project.py b/tests/controller/test_export_project.py index 02877bda..d8db6fb3 100644 --- a/tests/controller/test_export_project.py +++ b/tests/controller/test_export_project.py @@ -19,7 +19,6 @@ import os import json import pytest -import pytest_asyncio import aiohttp import zipfile @@ -33,7 +32,7 @@ from gns3server.controller.export_project import export_project, _is_exportable from gns3server.utils.asyncio import aiozipstream -@pytest_asyncio.fixture +@pytest.fixture async def project(controller): p = Project(controller=controller, name="test") @@ -41,7 +40,7 @@ async def project(controller): return p -@pytest_asyncio.fixture +@pytest.fixture async def node(controller, project): compute = MagicMock() diff --git a/tests/controller/test_link.py b/tests/controller/test_link.py index 25a82404..702dbdc2 100644 --- a/tests/controller/test_link.py +++ b/tests/controller/test_link.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio import aiohttp from unittest.mock import MagicMock @@ -27,7 +26,7 @@ from gns3server.controller.ports.serial_port import SerialPort from tests.utils import AsyncioBytesIO, AsyncioMagicMock -@pytest_asyncio.fixture +@pytest.fixture async def link(project, compute): node1 = Node(project, compute, "node1", node_type="qemu") diff --git a/tests/controller/test_notification.py b/tests/controller/test_notification.py index ab2c0f39..d0cc4e3d 100644 --- a/tests/controller/test_notification.py +++ b/tests/controller/test_notification.py @@ -15,13 +15,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest_asyncio +import pytest from unittest.mock import MagicMock from tests.utils import AsyncioMagicMock -@pytest_asyncio.fixture +@pytest.fixture async def node(project): compute = MagicMock() diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index 48c8a758..bc729fee 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -20,7 +20,6 @@ import os import sys import uuid import pytest -import pytest_asyncio import aiohttp from unittest.mock import MagicMock from tests.utils import AsyncioMagicMock, asyncio_patch @@ -34,7 +33,7 @@ from gns3server.controller.ports.ethernet_port import EthernetPort from gns3server.config import Config -@pytest_asyncio.fixture +@pytest.fixture async def node(controller, project): compute = MagicMock() diff --git a/tests/handlers/api/compute/test_docker.py b/tests/handlers/api/compute/test_docker.py index 878c99c0..217fb3b0 100644 --- a/tests/handlers/api/compute/test_docker.py +++ b/tests/handlers/api/compute/test_docker.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio import sys import uuid @@ -53,7 +52,7 @@ def base_params(): # Docker._instance = None -@pytest_asyncio.fixture +@pytest.fixture async def vm(compute_api, compute_project, base_params): with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "nginx"}]): diff --git a/tests/handlers/api/compute/test_iou.py b/tests/handlers/api/compute/test_iou.py index f54c926b..aadb4fa0 100644 --- a/tests/handlers/api/compute/test_iou.py +++ b/tests/handlers/api/compute/test_iou.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio import os import stat import sys @@ -46,7 +45,7 @@ def base_params(tmpdir, fake_iou_bin): return {"application_id": 42, "name": "PC TEST 1", "path": "iou.bin"} -@pytest_asyncio.fixture +@pytest.fixture async def vm(compute_api, compute_project, base_params): response = await compute_api.post("/projects/{project_id}/iou/nodes".format(project_id=compute_project.id), base_params) diff --git a/tests/handlers/api/compute/test_qemu.py b/tests/handlers/api/compute/test_qemu.py index 7575a0b4..00245f25 100644 --- a/tests/handlers/api/compute/test_qemu.py +++ b/tests/handlers/api/compute/test_qemu.py @@ -16,7 +16,6 @@ # along with this program. If not, see . import pytest -import pytest_asyncio import uuid import os import sys @@ -58,7 +57,7 @@ def base_params(tmpdir, fake_qemu_bin): return {"name": "PC TEST 1", "qemu_path": fake_qemu_bin} -@pytest_asyncio.fixture +@pytest.fixture async def vm(compute_api, compute_project, base_params): response = await compute_api.post("/projects/{project_id}/qemu/nodes".format(project_id=compute_project.id), base_params) diff --git a/tests/handlers/api/compute/test_vpcs.py b/tests/handlers/api/compute/test_vpcs.py index 70ee8294..f75aba85 100644 --- a/tests/handlers/api/compute/test_vpcs.py +++ b/tests/handlers/api/compute/test_vpcs.py @@ -15,13 +15,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest_asyncio +import pytest import uuid from tests.utils import asyncio_patch from unittest.mock import patch -@pytest_asyncio.fixture +@pytest.fixture async def vm(compute_api, compute_project): params = {"name": "PC TEST 1"} diff --git a/tests/handlers/api/controller/test_link.py b/tests/handlers/api/controller/test_link.py index 67c77a47..be87b74b 100644 --- a/tests/handlers/api/controller/test_link.py +++ b/tests/handlers/api/controller/test_link.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest_asyncio +import pytest from unittest.mock import patch, MagicMock from tests.utils import asyncio_patch, AsyncioMagicMock @@ -24,7 +24,7 @@ from gns3server.controller.ports.ethernet_port import EthernetPort from gns3server.controller.link import Link, FILTERS -@pytest_asyncio.fixture +@pytest.fixture async def nodes(compute, project): response = MagicMock() diff --git a/tests/handlers/api/controller/test_project.py b/tests/handlers/api/controller/test_project.py index 035c96b4..ed8aeb22 100644 --- a/tests/handlers/api/controller/test_project.py +++ b/tests/handlers/api/controller/test_project.py @@ -18,7 +18,6 @@ import uuid import os import pytest -import pytest_asyncio import zipfile import json @@ -26,7 +25,7 @@ from unittest.mock import patch, MagicMock from tests.utils import asyncio_patch -@pytest_asyncio.fixture +@pytest.fixture async def project(controller_api, controller): u = str(uuid.uuid4()) diff --git a/tests/handlers/api/controller/test_snapshot.py b/tests/handlers/api/controller/test_snapshot.py index 034470c8..faed67df 100644 --- a/tests/handlers/api/controller/test_snapshot.py +++ b/tests/handlers/api/controller/test_snapshot.py @@ -17,10 +17,10 @@ import os import uuid -import pytest_asyncio +import pytest -@pytest_asyncio.fixture +@pytest.fixture async def project(controller_api, controller): u = str(uuid.uuid4()) @@ -30,7 +30,7 @@ async def project(controller_api, controller): return project -@pytest_asyncio.fixture +@pytest.fixture async def snapshot(project): snapshot = await project.snapshot("test")