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 stop(vm_name): """ Stop a VM """ myvm = VM(vm_name) myvm.stop()