- Include the unpickling code in the 'try' block, so that an exception raised
during unpickling will not fail the test.
- Change the default env (returned by load_env() when the file is missing or
corrupt) to {}.
Signed-off-by: Michael Goldish <[email protected]>
---
client/tests/kvm/kvm_utils.py | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index d386456..cc39b5d 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -22,7 +22,7 @@ def dump_env(obj, filename):
file.close()
-def load_env(filename, default=None):
+def load_env(filename, default={}):
"""
Load KVM test environment from an environment file.
@@ -30,11 +30,13 @@ def load_env(filename, default=None):
"""
try:
file = open(filename, "r")
+ obj = cPickle.load(file)
+ file.close()
+ return obj
+ # Almost any exception can be raised during unpickling, so let's catch
+ # them all
except:
return default
- obj = cPickle.load(file)
- file.close()
- return obj
def get_sub_dict(dict, name):
--
1.5.4.1
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest