lmr,
Excellent, I like it. I've been massaging a libvirt_xml/xml_utils update that will also allow me to push all those virsh global into their respective classes anyway, so your change will fit nicely, and allow virsh_unittest. Thanks!
On 09/24/2012 08:44 AM, Lucas Meneghel Rodrigues wrote:
This is a solution for issue #563. If one is only testing kvm components, for example, the absence of virsh should not be relevant, but since the module throws an exception on import, and module is imported on env_processing, a ValueError will be thrown and fail completely all the tests. Let's fail things only when actual functionality of the module is called, during the initialization of the BaseVirsh class. CC: Chris Evich<[email protected]> Signed-off-by: Lucas Meneghel Rodrigues<[email protected]> --- client/tests/virt/virttest/virsh.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/tests/virt/virttest/virsh.py b/client/tests/virt/virttest/virsh.py index 90c2955..1f7d24c 100644 --- a/client/tests/virt/virttest/virsh.py +++ b/client/tests/virt/virttest/virsh.py @@ -38,7 +38,11 @@ _NOCLOSE = MODULE_CONTENTS.keys() + [ ] # default virsh executable -VIRSH_EXEC = os_dep.command("virsh") +try: + VIRSH_EXEC = os_dep.command("virsh") +except ValueError: + VIRSH_EXEC = None + logging.info("Command 'virsh' is not installed, please install it") # Virsh class properties and default values # Schema: {<name>:<default>} @@ -97,6 +101,9 @@ class VirshBase(dict): """ Initialize libvirt connection/state from VIRSH_PROPERTIES and/or dargs """ + if VIRSH_EXEC is None: + raise ValueError("Command Virsh is not installed, " + "please install it.") # Setup defaults, (calls properties) _dargs = VIRSH_PROPERTIES.copy() _dargs.update(dargs)
-- Chris Evich, RHCA, RHCE, RHCDS, RHCSS Quality Assurance Engineer e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214 _______________________________________________ Autotest-kernel mailing list [email protected] https://www.redhat.com/mailman/listinfo/autotest-kernel
