def test_freebsd_vm(): fp = abspath('tests/freebsd.conf') vm = VM(fp) vm.save() yield vm if vm.status() == "Stopped": vm.start() vm.delete()
def test_vm_stop_non_graceful_fail(monkeypatch): # We want to catch the VM fp = abspath('tests/freebsd.conf') test_freebsd_vm = VM(fp) if test_freebsd_vm.status() == "Stopped": test_freebsd_vm.start() def mockfalse(): return 111 monkeypatch.setattr(test_freebsd_vm, 'get_pid', mockfalse) with pytest.raises(OSError, match="VM did not die when it was supposed to"): test_freebsd_vm.stop() monkeypatch.undo()
def start(vm_name): """ Start a VM """ myvm = VM(vm_name) myvm.start()