[Libvirt-cim] [PATCH] [TEST] #2 Remove uses of "finally" keyword

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Apr 15 18:26:35 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1208283972 25200
# Node ID 22fa9f89fddbe1892f0c5fa10ce60027dd171059
# Parent  b9ce0dcc277e51d5865b611ebd092874e856bbe2
[TEST] #2 Remove uses of "finally" keyword.

python2.4 doesn't support it, and in most cases, it isn't needed.

Updates:
 -Nothing changed.  The system has an appropriate time set now.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py	Tue Apr 15 11:26:12 2008 -0700
@@ -115,9 +115,8 @@ RequestedStateChange()", action, default
         logger.error("Exception: %s", detail)
         status = FAIL
 
-    finally:
-        # undefine the vs
-        undefine_test_domain(default_dom, options.ip, options.virt)
+    # undefine the vs
+    undefine_test_domain(default_dom, options.ip, options.virt)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py	Tue Apr 15 11:26:12 2008 -0700
@@ -114,9 +114,8 @@ RequestedStateChange()", action, default
         logger.error("Exception: %s", detail)
         status = FAIL
 
-    finally:
-        # undefine the vs
-        undefine_test_domain(default_dom, options.ip, options.virt)
+    # undefine the vs
+    undefine_test_domain(default_dom, options.ip, options.virt)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/33_suspend_reboot.py	Tue Apr 15 11:26:12 2008 -0700
@@ -118,9 +118,8 @@ RequestedStateChange()", action, default
         logger.error("Exception: %s", detail)
         status = FAIL
 
-    finally:
-        # undefine the vs
-        undefine_test_domain(default_dom, options.ip, options.virt)
+    # undefine the vs
+    undefine_test_domain(default_dom, options.ip, options.virt)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/35_start_reset.py	Tue Apr 15 11:26:12 2008 -0700
@@ -115,9 +115,8 @@ RequestedStateChange()", action, default
         logger.error("Exception: %s", detail)
         status = FAIL
 
-    finally:
-        # undefine the vs
-        undefine_test_domain(default_dom, options.ip, options.virt)
+    # undefine the vs
+    undefine_test_domain(default_dom, options.ip, options.virt)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ComputerSystem/40_RSC_start.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/40_RSC_start.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/40_RSC_start.py	Tue Apr 15 11:26:12 2008 -0700
@@ -95,8 +95,7 @@ def main():
         logger.error("Exception: %s", detail)
         status = rc
 
-    finally:
-        undefine_test_domain(default_dom, options.ip, options.virt)
+    undefine_test_domain(default_dom, options.ip, options.virt)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py
--- a/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py	Tue Apr 15 11:26:12 2008 -0700
@@ -80,11 +80,11 @@ def main():
     except Exception, details:
             logger.error("Unknown exception happened")
             logger.error(details)
-    finally:    
-        sub.unsubscribe(dict['default_auth'])
-        logger.info("Cancelling subscription for %s" % indication_name)
-        os.kill(pid, signal.SIGKILL)
-        undefine_test_domain(test_dom, options.ip, options.virt)
+
+    sub.unsubscribe(dict['default_auth'])
+    logger.info("Cancelling subscription for %s" % indication_name)
+    os.kill(pid, signal.SIGKILL)
+    undefine_test_domain(test_dom, options.ip, options.virt)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ElementCapabilities/03_forward_errs.py
--- a/suites/libvirt-cim/cimtest/ElementCapabilities/03_forward_errs.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementCapabilities/03_forward_errs.py	Tue Apr 15 11:26:12 2008 -0700
@@ -55,11 +55,11 @@ def try_assoc(ref, ref_class, exp_rc, ex
     except Exception, details:
         logger.error("Unknown exception happened")
         logger.error(details)
-    finally:
-        if rc == 0:
-            logger.error("ElementCapabilities associator should NOT return excepted \
-                         result with a wrong key name and value of %s input" % ref_class)
-            status = FAIL
+
+    if rc == 0:
+        logger.error("ElementCapabilities associator should NOT return excepted \
+                      result with a wrong key name and value of %s input" % ref_class)
+        status = FAIL
      
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ElementCapabilities/04_reverse_errs.py
--- a/suites/libvirt-cim/cimtest/ElementCapabilities/04_reverse_errs.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementCapabilities/04_reverse_errs.py	Tue Apr 15 11:26:12 2008 -0700
@@ -54,11 +54,11 @@ def try_assoc(ref, ref_class, exp_rc, ex
     except Exception, details:
         logger.error("Unknown exception happened")
         logger.error(details)
-    finally:
-        if rc == 0:
-            logger.error("ElementCapabilities associator should NOT return excepted result \
-                         with a wrong key name and value of %s input" % ref_class)
-            status = FAIL
+
+    if rc == 0:
+        logger.error("ElementCapabilities associator should NOT return excepted result \
+                      with a wrong key name and value of %s input" % ref_class)
+        status = FAIL
     
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/HostedService/03_forward_errs.py
--- a/suites/libvirt-cim/cimtest/HostedService/03_forward_errs.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/HostedService/03_forward_errs.py	Tue Apr 15 11:26:12 2008 -0700
@@ -68,10 +68,10 @@ def main():
     except Exception, details:
         logger.error("Unknown exception happened")
         logger.error(details)
-    finally:
-        if rc == 0:
-            logger.error("HostedService associator should NOT return excepted result with a wrong key name and value of HostSystem input")
-            status = FAIL
+
+    if rc == 0:
+        logger.error("HostedService associator should NOT return excepted result with a wrong key name and value of HostSystem input")
+        status = FAIL
     
     return status        
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py
--- a/suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py	Tue Apr 15 11:26:12 2008 -0700
@@ -76,10 +76,10 @@ def main():
         except Exception, details:
             logger.error("Unknown exception happened")
             logger.error(details)
-        finally:
-            if rc == 0:
-                logger.error("HostedService associator should NOT return excepted result with a wrong key name and value of %s input" % k)
-                status = FAIL
+
+        if rc == 0:
+            logger.error("HostedService associator should NOT return excepted result with a wrong key name and value of %s input" % k)
+            status = FAIL
                 
         return status        
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/Memory/02_defgetmem.py
--- a/suites/libvirt-cim/cimtest/Memory/02_defgetmem.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/Memory/02_defgetmem.py	Tue Apr 15 11:26:12 2008 -0700
@@ -83,8 +83,7 @@ def main():
         logger.error("Exception: %s" % detail)
         status = 1
 
-    finally:
-        undefine_test_domain(default_dom, options.ip)
+    undefine_test_domain(default_dom, options.ip)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/Processor/02_definesys_get_procs.py
--- a/suites/libvirt-cim/cimtest/Processor/02_definesys_get_procs.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/Processor/02_definesys_get_procs.py	Tue Apr 15 11:26:12 2008 -0700
@@ -96,8 +96,7 @@ def main():
         logger.error("Exception: %s" % detail)
         status = 1
 
-    finally:
-        undefine_test_domain(default_dom, options.ip)
+    undefine_test_domain(default_dom, options.ip)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ResourceAllocationFromPool/03_forward_errs.py
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/03_forward_errs.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/03_forward_errs.py	Tue Apr 15 11:26:12 2008 -0700
@@ -66,10 +66,10 @@ def main():
         except Exception, details:
             logger.error("Unknown exception happened")
             logger.error(details)
-        finally:
-            if rc == 0:
-                logger.error("ResourceAllocationFromPool associator should NOT return excepted result with a wrong InstanceID value of %s input" %k)
-                status = FAIL
+
+        if rc == 0:
+            logger.error("ResourceAllocationFromPool associator should NOT return excepted result with a wrong InstanceID value of %s input" %k)
+            status = FAIL
         
         return status        
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/ResourceAllocationFromPool/04_reverse_errs.py
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/04_reverse_errs.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/04_reverse_errs.py	Tue Apr 15 11:26:12 2008 -0700
@@ -65,10 +65,10 @@ def main():
         except Exception, details:
             logger.error("Unknown exception happened")
             logger.error(details)
-        finally:
-            if rc == 0:
-                logger.error("ResourceAllocationSettingData should NOT return excepted result with a wrong InstanceID value of %s input" %k)
-                status = FAIL
+
+        if rc == 0:
+            logger.error("ResourceAllocationSettingData should NOT return excepted result with a wrong InstanceID value of %s input" %k)
+            status = FAIL
         
         return status        
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py
--- a/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/SystemDevice/03_fwderrs.py	Tue Apr 15 11:26:12 2008 -0700
@@ -155,12 +155,11 @@ def main():
                         logger.info(details)
                         status = FAIL
 
-                    finally:
-                        if rc == 0:
-                            logger.info("Success returned for wrong key and ID")
-                            logger.info("Class = %s , key = %s , keyval = %s " %
-                                        (item, i , keyval))
-                            return XFAIL_RC(bug)
+                    if rc == 0:
+                        logger.info("Success returned for wrong key and ID")
+                        logger.info("Class = %s , key = %s , keyval = %s " %
+                                     (item, i , keyval))
+                        return XFAIL_RC(bug)
 
             except Exception, details:
                 logger.info("exception" , details)
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py	Tue Apr 15 11:26:12 2008 -0700
@@ -93,8 +93,8 @@ def main():
     except Exception, details:
         logger.error('Error invoking AddRS')
         logger.error(details)
-    finally:
-        cxml.undefine(options.ip)
+
+    cxml.undefine(options.ip)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/VirtualSystemManagementService/07_addresource_neg.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/07_addresource_neg.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/07_addresource_neg.py	Tue Apr 15 11:26:12 2008 -0700
@@ -74,10 +74,10 @@ def main():
         logger.error('Error invoking AddRS')
         logger.error(details)
         status = FAIL
-    finally:
-        cxml.undefine(options.ip)
-        if rc == 0:
-            return XFAIL_RC(bug)
+
+    cxml.undefine(options.ip)
+    if rc == 0:
+        return XFAIL_RC(bug)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py	Tue Apr 15 11:26:12 2008 -0700
@@ -96,10 +96,10 @@ def main():
         logger.error('Error invoking ModifyRS')
         logger.error(details)
         return XFAIL_RC(bug_net)
-    finally:
-        cxml.undefine(options.ip)
-        if rc == -1:
-            return XFAIL_RC(bug_cpu)
+
+    cxml.undefine(options.ip)
+    if rc == -1:
+        return XFAIL_RC(bug_cpu)
 
     return status
 
diff -r b9ce0dcc277e -r 22fa9f89fddb suites/libvirt-cim/cimtest/VirtualSystemMigrationService/05_migratable_host_errs.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/05_migratable_host_errs.py	Mon Apr 14 01:16:57 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/05_migratable_host_errs.py	Tue Apr 15 11:26:12 2008 -0700
@@ -84,9 +84,9 @@ def main():
     except Exception, details:
         logger.error('Unknown exception happened')
         logger.error(details)
-    finally:
-        if rc == 0:
-            logger.error('Migrate to host method should NOT return OK with a wrong key input')
+
+    if rc == 0:
+        logger.error('Migrate to host method should NOT return OK with a wrong key input')
 
     destroy_and_undefine_domain(test_dom, options.ip)
     return status




More information about the Libvirt-cim mailing list