[Libvirt-cim] [PATCH 3 of 3] [TEST] IPv6 Support test

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Dec 3 18:06:50 UTC 2009


> +
> +            if vp != dev.VideoProcessor:
> +                vsmxl.undefine(server)
> +                raise Exception("Unxpected VNC server address")
> +
> +            vnc = get_typed_class(virt, "GraphicsResourceAllocationSettingData")
> +            key_list = { 'InstanceID' : devid,
> +                         'CreationClassName' : vnc,
> +                         'SystemName' : test_dom,
> +                         'SystemCreationClassName' : 
> +                         get_typed_class(virt, "ComputerSystem")
> +                       }
> +            dev = GetInstance(server, vnc, key_list)
> +
> +            if value != dev.Address:
> +                vsmxl.undefine(server)
> +                raise Exception("Unxpected VNC server address")
> +
> +            vsxml.undefine(server)
> +    		
> +    except Exception, detail:
> +        logger.error("Exception: %s", detail)
> +        status = FAIL

Instead of calling undefine before each call to raise Exception(), why 
not put the undefine call in the except block?  This means you'll only 
need to call undefine() once for any exception.  And if this test case 
is extended in the future, it'll safe guard against an accidental 
exclusion of the undefine() call when an exception occurs.

> +
> +    return status
> +
> +if __name__ == "__main__":
> +    sys.exit(main())
> 
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim




More information about the Libvirt-cim mailing list