diff --git a/dev-requirements.txt b/dev-requirements.txt
index f02ff2a2..6f964e26 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,8 +1,8 @@
-r requirements.txt
-pytest==7.0.0
-flake8==4.0.1
-pytest-timeout==2.0.1
-pytest-asyncio==0.16.0
-requests==2.26.0
-httpx==0.21.1
+pytest==7.1.2
+flake8==5.0.4
+pytest-timeout==2.1.0
+pytest-asyncio==0.19.0
+requests==2.28.1
+httpx==0.23.0
diff --git a/tests/api/routes/compute/test_cloud_nodes.py b/tests/api/routes/compute/test_cloud_nodes.py
index 6ea9f3cc..b29f8a2b 100644
--- a/tests/api/routes/compute/test_cloud_nodes.py
+++ b/tests/api/routes/compute/test_cloud_nodes.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -27,7 +28,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio
-@pytest.fixture(scope="function")
+@pytest_asyncio.fixture(scope="function")
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, on_gns3vm) -> dict:
with asyncio_patch("gns3server.compute.builtin.nodes.cloud.Cloud._start_ubridge"):
diff --git a/tests/api/routes/compute/test_docker_nodes.py b/tests/api/routes/compute/test_docker_nodes.py
index cacbcf30..f8c7935e 100644
--- a/tests/api/routes/compute/test_docker_nodes.py
+++ b/tests/api/routes/compute/test_docker_nodes.py
@@ -16,7 +16,7 @@
# along with this program. If not, see .
import pytest
-import sys
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -55,7 +55,7 @@ def base_params() -> dict:
# Docker._instance = None
-@pytest.fixture
+@pytest_asyncio.fixture
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, base_params: dict) -> dict:
with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "nginx"}]):
diff --git a/tests/api/routes/compute/test_iou_nodes.py b/tests/api/routes/compute/test_iou_nodes.py
index 61309345..d894ac30 100644
--- a/tests/api/routes/compute/test_iou_nodes.py
+++ b/tests/api/routes/compute/test_iou_nodes.py
@@ -16,9 +16,9 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
import os
import stat
-import sys
import uuid
from fastapi import FastAPI, status
@@ -49,7 +49,7 @@ def base_params(tmpdir, fake_iou_bin) -> dict:
return {"application_id": 42, "name": "IOU-TEST-1", "path": "iou.bin"}
-@pytest.fixture
+@pytest_asyncio.fixture
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, base_params: dict) -> dict:
response = await compute_client.post(app.url_path_for("compute:create_iou_node", project_id=compute_project.id), json=base_params)
diff --git a/tests/api/routes/compute/test_nat_nodes.py b/tests/api/routes/compute/test_nat_nodes.py
index 67913785..0f8b0d69 100644
--- a/tests/api/routes/compute/test_nat_nodes.py
+++ b/tests/api/routes/compute/test_nat_nodes.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -26,7 +27,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio
-@pytest.fixture(scope="function")
+@pytest_asyncio.fixture(scope="function")
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, ubridge_path: str, on_gns3vm) -> dict:
with asyncio_patch("gns3server.compute.builtin.nodes.nat.Nat._start_ubridge"):
diff --git a/tests/api/routes/compute/test_qemu_nodes.py b/tests/api/routes/compute/test_qemu_nodes.py
index 9cc14bf8..f0d3a44d 100644
--- a/tests/api/routes/compute/test_qemu_nodes.py
+++ b/tests/api/routes/compute/test_qemu_nodes.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
import os
import stat
import shutil
@@ -69,7 +70,7 @@ def base_params(tmpdir, fake_qemu_bin) -> dict:
return {"name": "QEMU-TEST-1", "qemu_path": fake_qemu_bin}
-@pytest.fixture
+@pytest_asyncio.fixture
async def qemu_vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, base_params: dict) -> None:
response = await compute_client.post(
diff --git a/tests/api/routes/compute/test_virtualbox_nodes.py b/tests/api/routes/compute/test_virtualbox_nodes.py
index 30ffe139..5a88b6d7 100644
--- a/tests/api/routes/compute/test_virtualbox_nodes.py
+++ b/tests/api/routes/compute/test_virtualbox_nodes.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -27,7 +28,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio
-@pytest.fixture(scope="function")
+@pytest_asyncio.fixture(scope="function")
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project) -> None:
vboxmanage_path = "/fake/VboxManage"
diff --git a/tests/api/routes/compute/test_vmware_nodes.py b/tests/api/routes/compute/test_vmware_nodes.py
index 7ac81ef4..088b4db2 100644
--- a/tests/api/routes/compute/test_vmware_nodes.py
+++ b/tests/api/routes/compute/test_vmware_nodes.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -27,7 +28,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio
-@pytest.fixture(scope="function")
+@pytest_asyncio.fixture(scope="function")
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, vmx_path: str) -> dict:
params = {
diff --git a/tests/api/routes/compute/test_vpcs_nodes.py b/tests/api/routes/compute/test_vpcs_nodes.py
index e49a84bb..f0b69366 100644
--- a/tests/api/routes/compute/test_vpcs_nodes.py
+++ b/tests/api/routes/compute/test_vpcs_nodes.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -27,7 +28,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio
-@pytest.fixture
+@pytest_asyncio.fixture
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project) -> None:
params = {"name": "PC TEST 1"}
diff --git a/tests/api/routes/controller/test_groups.py b/tests/api/routes/controller/test_groups.py
index 4e0700bb..e8d6e791 100644
--- a/tests/api/routes/controller/test_groups.py
+++ b/tests/api/routes/controller/test_groups.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -171,7 +172,7 @@ class TestGroupMembersRoutes:
assert len(members) == 0
-@pytest.fixture
+@pytest_asyncio.fixture
async def test_role(db_session: AsyncSession) -> Role:
new_role = schemas.RoleCreate(
diff --git a/tests/api/routes/controller/test_links.py b/tests/api/routes/controller/test_links.py
index bab91d88..139fb3ff 100644
--- a/tests/api/routes/controller/test_links.py
+++ b/tests/api/routes/controller/test_links.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from typing import Tuple
from fastapi import FastAPI, status
@@ -34,7 +35,7 @@ from gns3server.controller.udp_link import UDPLink
pytestmark = pytest.mark.asyncio
-@pytest.fixture
+@pytest_asyncio.fixture
async def nodes(compute: Compute, project: Project) -> Tuple[Node, Node]:
response = MagicMock()
diff --git a/tests/api/routes/controller/test_permissions.py b/tests/api/routes/controller/test_permissions.py
index 5553648d..d35583f1 100644
--- a/tests/api/routes/controller/test_permissions.py
+++ b/tests/api/routes/controller/test_permissions.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
import uuid
from fastapi import FastAPI, status
@@ -31,7 +32,7 @@ pytestmark = pytest.mark.asyncio
class TestPermissionRoutes:
- @pytest.fixture()
+ @pytest_asyncio.fixture
async def project(self, app: FastAPI, client: AsyncClient, controller: Controller) -> Project:
project_uuid = str(uuid.uuid4())
diff --git a/tests/api/routes/controller/test_projects.py b/tests/api/routes/controller/test_projects.py
index e347707a..ebbd219b 100644
--- a/tests/api/routes/controller/test_projects.py
+++ b/tests/api/routes/controller/test_projects.py
@@ -19,6 +19,7 @@ import uuid
import os
import json
import pytest
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -32,7 +33,7 @@ from gns3server.controller.project import Project
pytestmark = pytest.mark.asyncio
-@pytest.fixture
+@pytest_asyncio.fixture
async def project(app: FastAPI, client: AsyncClient, controller: Controller) -> Project:
u = str(uuid.uuid4())
diff --git a/tests/api/routes/controller/test_roles.py b/tests/api/routes/controller/test_roles.py
index 0ffe0b1a..600ca89d 100644
--- a/tests/api/routes/controller/test_roles.py
+++ b/tests/api/routes/controller/test_roles.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -105,7 +106,7 @@ class TestRolesRoutes:
assert response.status_code == status.HTTP_403_FORBIDDEN
-@pytest.fixture
+@pytest_asyncio.fixture
async def test_permission(db_session: AsyncSession) -> Permission:
new_permission = schemas.PermissionCreate(
diff --git a/tests/api/routes/controller/test_snapshots.py b/tests/api/routes/controller/test_snapshots.py
index 7b7749e5..3058cdad 100644
--- a/tests/api/routes/controller/test_snapshots.py
+++ b/tests/api/routes/controller/test_snapshots.py
@@ -18,6 +18,7 @@
import os
import uuid
import pytest
+import pytest_asyncio
from fastapi import FastAPI, status
from httpx import AsyncClient
@@ -29,7 +30,7 @@ from gns3server.controller.snapshot import Snapshot
pytestmark = pytest.mark.asyncio
-@pytest.fixture
+@pytest_asyncio.fixture
async def project(app: FastAPI, client: AsyncClient, controller: Controller) -> Project:
u = str(uuid.uuid4())
@@ -39,7 +40,7 @@ async def project(app: FastAPI, client: AsyncClient, controller: Controller) ->
return project
-@pytest.fixture
+@pytest_asyncio.fixture
async def snapshot(project: Project):
snapshot = await project.snapshot("test")
diff --git a/tests/api/routes/controller/test_users.py b/tests/api/routes/controller/test_users.py
index 042c2b32..971961ad 100644
--- a/tests/api/routes/controller/test_users.py
+++ b/tests/api/routes/controller/test_users.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from typing import Optional
from fastapi import FastAPI, HTTPException, status
@@ -438,7 +439,8 @@ class TestSuperAdmin:
# assert response.status_code == status.HTTP_200_OK
# assert len(response.json()) == 1
-@pytest.fixture
+
+@pytest_asyncio.fixture
async def test_permission(db_session: AsyncSession) -> Permission:
new_permission = schemas.PermissionCreate(
diff --git a/tests/compute/builtin/nodes/test_cloud.py b/tests/compute/builtin/nodes/test_cloud.py
index a45718fe..7a482260 100644
--- a/tests/compute/builtin/nodes/test_cloud.py
+++ b/tests/compute/builtin/nodes/test_cloud.py
@@ -17,6 +17,7 @@
import uuid
import pytest
+import pytest_asyncio
from unittest.mock import MagicMock, patch, call
from gns3server.compute.builtin.nodes.cloud import Cloud
@@ -30,8 +31,7 @@ def nio():
return NIOUDP(4242, "127.0.0.1", 4343)
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def manager():
m = MagicMock()
diff --git a/tests/compute/docker/test_docker.py b/tests/compute/docker/test_docker.py
index c118d03e..5155d4eb 100644
--- a/tests/compute/docker/test_docker.py
+++ b/tests/compute/docker/test_docker.py
@@ -16,6 +16,7 @@
# 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
@@ -23,8 +24,7 @@ from gns3server.compute.docker import Docker, DOCKER_PREFERRED_API_VERSION, DOCK
from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def vm():
vm = Docker()
diff --git a/tests/compute/docker/test_docker_vm.py b/tests/compute/docker/test_docker_vm.py
index 7088a643..e6e9ee9d 100644
--- a/tests/compute/docker/test_docker_vm.py
+++ b/tests/compute/docker/test_docker_vm.py
@@ -18,8 +18,8 @@
import aiohttp
import asyncio
import pytest
+import pytest_asyncio
import uuid
-import sys
import os
from tests.utils import asyncio_patch, AsyncioMagicMock
@@ -33,8 +33,7 @@ from gns3server.utils.get_resource import get_resource
from unittest.mock import patch, MagicMock, call
-@pytest.fixture()
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def manager(port_manager):
m = Docker.instance()
@@ -42,8 +41,7 @@ async def manager(port_manager):
return m
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def vm(compute_project, manager):
vm = DockerVM("test", str(uuid.uuid4()), compute_project, manager, "ubuntu:latest", aux_type="none")
diff --git a/tests/compute/dynamips/test_dynamips_manager.py b/tests/compute/dynamips/test_dynamips_manager.py
index 5665839f..94fd03e2 100644
--- a/tests/compute/dynamips/test_dynamips_manager.py
+++ b/tests/compute/dynamips/test_dynamips_manager.py
@@ -17,8 +17,8 @@
import pytest
+import pytest_asyncio
import tempfile
-import sys
import uuid
import os
@@ -28,8 +28,7 @@ from unittest.mock import patch
from tests.utils import asyncio_patch, AsyncioMagicMock
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.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 2dbcf881..5ececc90 100644
--- a/tests/compute/dynamips/test_dynamips_router.py
+++ b/tests/compute/dynamips/test_dynamips_router.py
@@ -18,7 +18,7 @@
import os
import uuid
import pytest
-import asyncio
+import pytest_asyncio
from gns3server.compute.dynamips.nodes.router import Router
from gns3server.compute.dynamips.dynamips_error import DynamipsError
@@ -26,8 +26,7 @@ from gns3server.compute.dynamips import Dynamips
from gns3server.config import Config
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.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 afd6fb78..76764ff5 100644
--- a/tests/compute/iou/test_iou_vm.py
+++ b/tests/compute/iou/test_iou_vm.py
@@ -16,11 +16,11 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
import asyncio
import os
import stat
import socket
-import sys
import uuid
import shutil
@@ -32,8 +32,7 @@ from gns3server.compute.iou.iou_error import IOUError
from gns3server.compute.iou import IOU
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def manager(port_manager):
m = IOU.instance()
@@ -41,8 +40,7 @@ async def manager(port_manager):
return m
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def vm(compute_project, manager, config, tmpdir, fake_iou_bin, iourc_file):
vm = IOUVM("test", str(uuid.uuid4()), compute_project, manager, application_id=1)
diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py
index c2b824ea..d5edc874 100644
--- a/tests/compute/qemu/test_qemu_vm.py
+++ b/tests/compute/qemu/test_qemu_vm.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
import asyncio
import os
import stat
@@ -32,8 +33,7 @@ from gns3server.utils import force_unix_path, macaddress_to_int, int_to_macaddre
from gns3server.compute.notification_manager import NotificationManager
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def manager(port_manager):
m = Qemu.instance()
@@ -63,8 +63,7 @@ def fake_qemu_binary(monkeypatch, tmpdir):
return bin_path
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def vm(compute_project, manager, fake_qemu_binary, fake_qemu_img_binary):
manager.port_manager.console_host = "127.0.0.1"
diff --git a/tests/compute/test_base_node.py b/tests/compute/test_base_node.py
index ea368672..58c06ff5 100644
--- a/tests/compute/test_base_node.py
+++ b/tests/compute/test_base_node.py
@@ -18,7 +18,7 @@
from collections import OrderedDict
import pytest
-import asyncio
+import pytest_asyncio
from tests.utils import asyncio_patch, AsyncioMagicMock
@@ -29,8 +29,7 @@ from gns3server.compute.vpcs import VPCS
from gns3server.compute.nios.nio_udp import NIOUDP
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def manager(port_manager):
m = VPCS.instance()
diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py
index a676b42a..e92a82ee 100644
--- a/tests/compute/test_manager.py
+++ b/tests/compute/test_manager.py
@@ -18,6 +18,7 @@
import uuid
import os
import pytest
+import pytest_asyncio
from unittest.mock import patch, MagicMock
from tests.utils import asyncio_patch
@@ -28,8 +29,7 @@ from gns3server.compute.error import NodeError, ImageMissingError
from gns3server.utils import force_unix_path
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def vpcs(port_manager):
VPCS._instance = None
@@ -38,8 +38,7 @@ async def vpcs(port_manager):
return vpcs
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def qemu(port_manager):
Qemu._instance = None
diff --git a/tests/compute/test_project.py b/tests/compute/test_project.py
index 6a8729c1..50f96792 100644
--- a/tests/compute/test_project.py
+++ b/tests/compute/test_project.py
@@ -19,6 +19,7 @@
import os
import uuid
import pytest
+import pytest_asyncio
from uuid import uuid4
from unittest.mock import patch
@@ -29,8 +30,7 @@ from gns3server.compute.compute_error import ComputeError, ComputeForbiddenError
from gns3server.compute.vpcs import VPCS, VPCSVM
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def manager(port_manager):
m = VPCS.instance()
@@ -38,8 +38,7 @@ async def manager(port_manager):
return m
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def node(compute_project, manager):
node = manager.create_node("test", compute_project.id, "00010203-0405-0607-0809-0a0b0c0d0e0f")
diff --git a/tests/compute/virtualbox/test_virtualbox_manager.py b/tests/compute/virtualbox/test_virtualbox_manager.py
index 2203c051..54d7e9f1 100644
--- a/tests/compute/virtualbox/test_virtualbox_manager.py
+++ b/tests/compute/virtualbox/test_virtualbox_manager.py
@@ -17,6 +17,7 @@
import pytest
+import pytest_asyncio
import tempfile
import os
import stat
@@ -28,7 +29,7 @@ from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
from tests.utils import asyncio_patch
-@pytest.fixture
+@pytest_asyncio.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 a69660db..5303834e 100644
--- a/tests/compute/virtualbox/test_virtualbox_vm.py
+++ b/tests/compute/virtualbox/test_virtualbox_vm.py
@@ -17,6 +17,7 @@
import os
import pytest
+import pytest_asyncio
from tests.utils import asyncio_patch, AsyncioMagicMock
from gns3server.compute.virtualbox.virtualbox_vm import VirtualBoxVM
@@ -24,8 +25,7 @@ from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
from gns3server.compute.virtualbox import VirtualBox
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def manager(port_manager):
m = VirtualBox.instance()
@@ -33,8 +33,7 @@ async def manager(port_manager):
return m
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def vm(compute_project, manager):
return VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager, "test", False)
diff --git a/tests/compute/vmware/test_vmware_manager.py b/tests/compute/vmware/test_vmware_manager.py
index 16e2ba61..7f2c2e0b 100644
--- a/tests/compute/vmware/test_vmware_manager.py
+++ b/tests/compute/vmware/test_vmware_manager.py
@@ -16,13 +16,12 @@
# along with this program. If not, see .
-import pytest
+import pytest_asyncio
from gns3server.compute.vmware import VMware
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.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 6b797c7b..631f07e1 100644
--- a/tests/compute/vmware/test_vmware_vm.py
+++ b/tests/compute/vmware/test_vmware_vm.py
@@ -16,13 +16,13 @@
# 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
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def manager(port_manager):
m = VMware.instance()
@@ -30,8 +30,7 @@ async def manager(port_manager):
return m
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def vm(compute_project, manager, tmpdir):
fake_vmx = str(tmpdir / "test.vmx")
diff --git a/tests/compute/vpcs/test_vpcs_vm.py b/tests/compute/vpcs/test_vpcs_vm.py
index a99c4e15..e85604f2 100644
--- a/tests/compute/vpcs/test_vpcs_vm.py
+++ b/tests/compute/vpcs/test_vpcs_vm.py
@@ -16,9 +16,9 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
import asyncio
import os
-import sys
from tests.utils import asyncio_patch, AsyncioMagicMock
from gns3server.utils import parse_version
@@ -30,8 +30,7 @@ from gns3server.compute.vpcs import VPCS
from gns3server.compute.notification_manager import NotificationManager
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def manager(port_manager):
m = VPCS.instance()
@@ -39,8 +38,7 @@ async def manager(port_manager):
return m
-@pytest.fixture(scope="function")
-@pytest.mark.asyncio
+@pytest_asyncio.fixture(scope="function")
async def vm(compute_project, manager, tmpdir, ubridge_path):
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager)
diff --git a/tests/conftest.py b/tests/conftest.py
index 81715666..579c4f78 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,5 +1,6 @@
import pytest
import asyncio
+import pytest_asyncio
import tempfile
import shutil
import sys
@@ -43,14 +44,14 @@ def event_loop(request):
loop.close()
-@pytest.fixture(scope="class")
+@pytest_asyncio.fixture(scope="class")
async def app() -> FastAPI:
from gns3server.api.server import app as gns3app
yield gns3app
-@pytest.fixture(scope="class")
+@pytest_asyncio.fixture(scope="class")
async def db_engine():
db_url = os.getenv("GNS3_TEST_DATABASE_URI", "sqlite+aiosqlite:///:memory:") # "sqlite:///./sql_test_app.db"
@@ -59,7 +60,7 @@ async def db_engine():
#await engine.sync_engine.dispose()
-@pytest.fixture(scope="class")
+@pytest_asyncio.fixture(scope="class")
async def db_session(db_engine):
# recreate database tables for each class
@@ -80,7 +81,7 @@ async def db_session(db_engine):
await session.close()
-@pytest.fixture
+@pytest_asyncio.fixture
async def base_client(app: FastAPI, db_session: AsyncSession) -> AsyncClient:
async def _get_test_db():
@@ -99,7 +100,7 @@ async def base_client(app: FastAPI, db_session: AsyncSession) -> AsyncClient:
yield async_client
-@pytest.fixture
+@pytest_asyncio.fixture
async def test_user(db_session: AsyncSession) -> User:
new_user = schemas.UserCreate(
@@ -119,7 +120,7 @@ async def test_user(db_session: AsyncSession) -> User:
return user
-@pytest.fixture
+@pytest_asyncio.fixture
async def test_compute(db_session: AsyncSession) -> Compute:
new_compute = schemas.ComputeCreate(
@@ -154,7 +155,7 @@ def authorized_client(base_client: AsyncClient, test_user: User) -> AsyncClient:
return base_client
-@pytest.fixture
+@pytest_asyncio.fixture
async def client(base_client: AsyncClient) -> AsyncClient:
# The super admin is automatically created when the users table is created
@@ -167,7 +168,7 @@ async def client(base_client: AsyncClient) -> AsyncClient:
return base_client
-@pytest.fixture
+@pytest_asyncio.fixture
async def compute_client(base_client: AsyncClient) -> AsyncClient:
# default compute username is 'admin'
@@ -206,8 +207,7 @@ def compute(controller):
return compute
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.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 5e5ece62..0a9be84f 100644
--- a/tests/controller/gns3vm/test_virtualbox_gns3_vm.py
+++ b/tests/controller/gns3vm/test_virtualbox_gns3_vm.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from tests.utils import asyncio_patch
from gns3server.utils.asyncio import wait_run_in_executor
@@ -23,8 +24,7 @@ from gns3server.utils.asyncio import wait_run_in_executor
from gns3server.controller.gns3vm.virtualbox_gns3_vm import VirtualBoxGNS3VM
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.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 78c8e95a..d0f661c1 100644
--- a/tests/controller/gns3vm/test_vmware_gns3_vm.py
+++ b/tests/controller/gns3vm/test_vmware_gns3_vm.py
@@ -16,12 +16,12 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from gns3server.controller.gns3vm.vmware_gns3_vm import VMwareGNS3VM
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.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 e1e0f1a7..507e30dd 100644
--- a/tests/controller/test_export_project.py
+++ b/tests/controller/test_export_project.py
@@ -19,6 +19,7 @@
import os
import json
import pytest
+import pytest_asyncio
import zipfile
from pathlib import Path
@@ -32,8 +33,7 @@ from gns3server.utils.asyncio import aiozipstream
from gns3server.controller.controller_error import ControllerError
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def project(controller):
p = Project(controller=controller, name="test")
@@ -41,8 +41,7 @@ async def project(controller):
return p
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def node(controller, project):
compute = MagicMock()
diff --git a/tests/controller/test_link.py b/tests/controller/test_link.py
index 9771de44..1448585e 100644
--- a/tests/controller/test_link.py
+++ b/tests/controller/test_link.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from unittest.mock import MagicMock
from gns3server.controller.link import Link
@@ -26,8 +27,7 @@ from gns3server.controller.controller_error import ControllerError
from tests.utils import AsyncioBytesIO, AsyncioMagicMock
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def link(project, compute):
node1 = Node(project, compute, "node1", node_type="qemu")
diff --git a/tests/controller/test_node_port_name.py b/tests/controller/test_node_port_name.py
index 0e254f9a..193f82ae 100644
--- a/tests/controller/test_node_port_name.py
+++ b/tests/controller/test_node_port_name.py
@@ -30,6 +30,7 @@ def compute():
s.id = "http://test.com:42"
return s
+
@pytest.fixture
def node(compute, project):
node = Node(project, compute, "demo",
diff --git a/tests/controller/test_notification.py b/tests/controller/test_notification.py
index 17be9d79..9204acea 100644
--- a/tests/controller/test_notification.py
+++ b/tests/controller/test_notification.py
@@ -16,13 +16,13 @@
# along with this program. If not, see .
import pytest
+import pytest_asyncio
from unittest.mock import MagicMock
from tests.utils import AsyncioMagicMock
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def node(project):
compute = MagicMock()
diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py
index f217ae4b..2469b669 100644
--- a/tests/controller/test_project.py
+++ b/tests/controller/test_project.py
@@ -17,9 +17,9 @@
# along with this program. If not, see .
import os
-import sys
import uuid
import pytest
+import pytest_asyncio
from unittest.mock import MagicMock
from tests.utils import AsyncioMagicMock, asyncio_patch
from unittest.mock import patch
@@ -32,8 +32,7 @@ from gns3server.controller.controller_error import ControllerError, ControllerNo
from gns3server.config import Config
-@pytest.fixture
-@pytest.mark.asyncio
+@pytest_asyncio.fixture
async def node(controller, project):
compute = MagicMock()