diff --git a/gns3server/handlers/__init__.py b/gns3server/handlers/__init__.py index c2247f30..464fa4a8 100644 --- a/gns3server/handlers/__init__.py +++ b/gns3server/handlers/__init__.py @@ -15,6 +15,8 @@ # along with this program. If not, see . import sys +import os + from gns3server.handlers.api.version_handler import VersionHandler from gns3server.handlers.api.network_handler import NetworkHandler from gns3server.handlers.api.project_handler import ProjectHandler @@ -25,5 +27,6 @@ from gns3server.handlers.api.virtualbox_handler import VirtualBoxHandler from gns3server.handlers.api.vpcs_handler import VPCSHandler from gns3server.handlers.upload_handler import UploadHandler -if sys.platform.startswith("linux"): +print(os.environ) +if sys.platform.startswith("linux") or hasattr(sys, "_called_from_test"): from gns3server.handlers.api.iou_handler import IOUHandler diff --git a/gns3server/modules/__init__.py b/gns3server/modules/__init__.py index 6b679996..4dce8ccc 100644 --- a/gns3server/modules/__init__.py +++ b/gns3server/modules/__init__.py @@ -23,7 +23,7 @@ from .qemu import Qemu MODULES = [VPCS, VirtualBox, Dynamips, Qemu] -if sys.platform.startswith("linux"): +if sys.platform.startswith("linux") or hasattr(sys, "_called_from_test"): # IOU runs only on Linux from .iou import IOU MODULES.append(IOU) diff --git a/tests/conftest.py b/tests/conftest.py index e9448aaf..b4599ce2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,14 +15,20 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . + import pytest import socket import asyncio import tempfile import shutil import os +import sys from aiohttp import web +sys._called_from_test = True +# Prevent execution of external binaries +os.environ["PATH"] = tempfile.mkdtemp() + from gns3server.config import Config from gns3server.web.route import Route # TODO: get rid of * @@ -33,10 +39,6 @@ from gns3server.modules.project_manager import ProjectManager from tests.handlers.api.base import Query -# Prevent execution of external binaries -os.environ["PATH"] = tempfile.mkdtemp() - - @pytest.yield_fixture def restore_original_path(): """