mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 16:54:51 +02:00
Use pytest 2.8 so it's work with Python 3.5 without warning
This commit is contained in:
parent
82540e5366
commit
69c38c6414
1
.gitignore
vendored
1
.gitignore
vendored
@ -24,6 +24,7 @@ pip-log.txt
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
.tox
|
||||
.cache
|
||||
nosetests.xml
|
||||
|
||||
# Translations
|
||||
|
@ -1,7 +1,7 @@
|
||||
-rrequirements.txt
|
||||
|
||||
sphinx==1.2.3
|
||||
pytest==2.6.4
|
||||
pytest==2.8.2
|
||||
pep8==1.5.7
|
||||
pytest-timeout
|
||||
pytest-capturelog
|
||||
|
@ -1426,6 +1426,8 @@ class QemuVM(BaseVM):
|
||||
:returns: Boolean True if we need to enable KVM
|
||||
"""
|
||||
|
||||
print(sys.platform.startswith("linux"))
|
||||
print(self.manager.config.get_section_config("Qemu").getboolean("enable_kvm", True))
|
||||
if sys.platform.startswith("linux") and self.manager.config.get_section_config("Qemu").getboolean("enable_kvm", True) \
|
||||
and "-no-kvm" not in options:
|
||||
|
||||
|
@ -77,7 +77,7 @@ def _get_unused_port():
|
||||
return port
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@pytest.fixture
|
||||
def server(request, loop, port_manager, monkeypatch):
|
||||
"""A GNS3 server"""
|
||||
|
||||
|
@ -389,7 +389,8 @@ def test_build_command_with_invalid_options(vm, loop, fake_qemu_binary):
|
||||
|
||||
def test_hda_disk_image(vm, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
||||
|
||||
vm.hda_disk_image = "/tmp/test"
|
||||
assert vm.hda_disk_image == "/tmp/test"
|
||||
vm.hda_disk_image = "test"
|
||||
@ -398,14 +399,16 @@ def test_hda_disk_image(vm, tmpdir):
|
||||
|
||||
def test_hda_disk_image_ova(vm, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
||||
|
||||
vm.hda_disk_image = "test.ovf/test.vmdk"
|
||||
assert vm.hda_disk_image == str(tmpdir / "QEMU" / "test.ovf" / "test.vmdk")
|
||||
|
||||
|
||||
def test_hdb_disk_image(vm, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
||||
|
||||
vm.hdb_disk_image = "/tmp/test"
|
||||
assert vm.hdb_disk_image == "/tmp/test"
|
||||
vm.hdb_disk_image = "test"
|
||||
@ -414,7 +417,8 @@ def test_hdb_disk_image(vm, tmpdir):
|
||||
|
||||
def test_hdc_disk_image(vm, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
||||
|
||||
vm.hdc_disk_image = "/tmp/test"
|
||||
assert vm.hdc_disk_image == "/tmp/test"
|
||||
vm.hdc_disk_image = "test"
|
||||
@ -423,7 +427,8 @@ def test_hdc_disk_image(vm, tmpdir):
|
||||
|
||||
def test_hdd_disk_image(vm, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
||||
|
||||
vm.hdd_disk_image = "/tmp/test"
|
||||
assert vm.hdd_disk_image == "/tmp/test"
|
||||
vm.hdd_disk_image = "test"
|
||||
@ -455,48 +460,41 @@ def test_get_qemu_img_not_exist(vm, tmpdir):
|
||||
|
||||
def test_run_with_kvm_darwin(darwin_platform, vm):
|
||||
|
||||
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
||||
vm.manager.config.set("Qemu", "enable_kvm", False)
|
||||
assert vm._run_with_kvm("qemu-system-x86_64", "") is False
|
||||
|
||||
|
||||
def test_run_with_kvm_windows(windows_platform, vm):
|
||||
|
||||
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
||||
vm.manager.config.set("Qemu", "enable_kvm", False)
|
||||
assert vm._run_with_kvm("qemu-system-x86_64.exe", "") is False
|
||||
|
||||
|
||||
def test_run_with_kvm_linux(linux_platform, vm):
|
||||
|
||||
with patch("os.path.exists", return_value=True) as os_path:
|
||||
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
||||
vm.manager.config.set("Qemu", "enable_kvm", True)
|
||||
assert vm._run_with_kvm("qemu-system-x86_64", "") is True
|
||||
os_path.assert_called_with("/dev/kvm")
|
||||
|
||||
|
||||
def test_run_with_kvm_linux_config_desactivated(linux_platform, vm):
|
||||
|
||||
with patch("os.path.exists", return_value=True) as os_path:
|
||||
with patch("configparser.SectionProxy.getboolean", return_value=False):
|
||||
assert vm._run_with_kvm("qemu-system-x86_64", "") is False
|
||||
|
||||
|
||||
def test_run_with_kvm_linux_options_no_kvm(linux_platform, vm):
|
||||
|
||||
with patch("os.path.exists", return_value=True) as os_path:
|
||||
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
||||
vm.manager.config.set("Qemu", "enable_kvm", True)
|
||||
assert vm._run_with_kvm("qemu-system-x86_64", "-no-kvm") is False
|
||||
|
||||
|
||||
def test_run_with_kvm_not_x86(linux_platform, vm):
|
||||
|
||||
with patch("os.path.exists", return_value=True) as os_path:
|
||||
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
||||
vm.manager.config.set("Qemu", "enable_kvm", True)
|
||||
assert vm._run_with_kvm("qemu-system-arm", "") is False
|
||||
|
||||
|
||||
def test_run_with_kvm_linux_dev_kvm_missing(linux_platform, vm):
|
||||
|
||||
with patch("os.path.exists", return_value=False) as os_path:
|
||||
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
||||
vm.manager.config.set("Qemu", "enable_kvm", True)
|
||||
with pytest.raises(QemuError):
|
||||
vm._run_with_kvm("qemu-system-x86_64", "")
|
||||
|
Loading…
Reference in New Issue
Block a user