mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 16:54:51 +02:00
Use pytest-asyncio auto mode
This commit is contained in:
parent
600c18f04b
commit
fc7d5be736
@ -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'
|
||||
|
@ -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()
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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()
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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()
|
||||
|
@ -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()
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -15,13 +15,12 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import pytest_asyncio
|
||||
import pytest
|
||||
|
||||
from gns3server.compute.vmware import VMware
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
@pytest.fixture
|
||||
async def manager(port_manager):
|
||||
|
||||
m = VMware.instance()
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
|
||||
from gns3server.compute.vmware.vmware_vm import VMwareVM
|
||||
from gns3server.compute.vmware import VMware
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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()
|
||||
|
@ -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")
|
||||
|
@ -15,7 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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)
|
||||
|
@ -16,12 +16,11 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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)
|
||||
|
@ -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()
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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")
|
||||
|
@ -15,13 +15,13 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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()
|
||||
|
@ -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()
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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"}]):
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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)
|
||||
|
@ -16,7 +16,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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)
|
||||
|
@ -15,13 +15,13 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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"}
|
||||
|
@ -15,7 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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()
|
||||
|
@ -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())
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user