diff mbox

[KVM-AUTOTEST,4/4] KVM test: boot test: change the scope of the try-finally statement

Message ID 1252918008-2742-4-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Sept. 14, 2009, 8:46 a.m. UTC
It's possible for the test to fail when there's no shell session to close, and
then session.close() in the finally clause raises a TypeError.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_tests.py |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index 446b415..43a6291 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -44,18 +44,17 @@  def run_boot(test, params, env):
                                   120, 0, 1):
             raise error.TestFail("Guest refuses to go down")
 
+    finally:
         session.close()
 
-        logging.info("Guest is down; waiting for it to go up again...")
-
-        session = kvm_utils.wait_for(vm.remote_login, 240, 0, 2)
-        if not session:
-            raise error.TestFail("Could not log into guest after reboot")
+    logging.info("Guest is down; waiting for it to go up again...")
 
-        logging.info("Guest is up again")
+    session = kvm_utils.wait_for(vm.remote_login, 240, 0, 2)
+    if not session:
+        raise error.TestFail("Could not log into guest after reboot")
+    session.close()
 
-    finally:
-        session.close()
+    logging.info("Guest is up again")
 
 
 def run_shutdown(test, params, env):