[libvirt] [test-API PATCH 2/4] don't pop out element from optional_params

Guannan Ren gren at redhat.com
Tue Apr 24 09:40:36 UTC 2012


This a bug, if we define a testcase that use xml file such as
'storage:define_dir_pool' more than once, the pop action will
result in that the second call to the testcases fails to get
xml string in 'xmlstr = params['xml']'
Because the 'xml' element is poped out previously
---
 src/testcasexml.py |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/src/testcasexml.py b/src/testcasexml.py
index 742116b..8485d3d 100644
--- a/src/testcasexml.py
+++ b/src/testcasexml.py
@@ -7,13 +7,12 @@ def xml_file_to_str(proxy_obj, mod_case, case_params):
     """ get xml string from xml file in case_params
         return a new case_params with the string in it
     """
-
     optional_params = proxy_obj.get_testcase_params(mod_case)[1]
 
     if case_params.has_key('xml'):
         file_name = case_params.pop('xml')
     elif optional_params.has_key('xml'):
-        file_name = optional_params.pop('xml')
+        file_name = optional_params['xml']
     else:
         return None
 
@@ -34,8 +33,6 @@ def xml_file_to_str(proxy_obj, mod_case, case_params):
     else:
         raise exception.FileDoesNotExist("xml file %s doesn't exist" % xml_file_path)
 
-    optional_params = proxy_obj.get_testcase_params(mod_case)[1]
-
     # replace the params that in testcase.conf first
     for (key, value) in case_params.items():
 
-- 
1.7.7.5




More information about the libvir-list mailing list