[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [test-API][PATCH 3/5] Update add_option_value function in parser



On 10/13/2011 07:30 PM, Wayne Sun wrote:
   * Option should be added to the last dictionary in caselist.
     The old function will cause problem when multiple dictionaries in
     caselist have same testkey.
---
  parser.py |   12 +++++-------
  1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/parser.py b/parser.py
index 8d41776..085a1f2 100644
--- a/parser.py
+++ b/parser.py
@@ -125,13 +125,11 @@ class CaseFileParser(object):

      def add_option_value(self, caselist, casename, option, value):
          """ Add option to the data list. """
-        for dictionary in caselist:
-            testkey = dictionary.keys()[0]
-            if casename == testkey:
-                if not dictionary[testkey].has_key(option):
-                    dictionary[testkey][option] = value
-            else:
-                continue
+        dictionary = caselist[-1]
+        testkey = dictionary.keys()[0]
+        if casename == testkey:
+            if not dictionary[testkey].has_key(option):
+                dictionary[testkey][option] = value

      def debug_print(self, str1, str2=""):
          """Nicely print two strings and an arrow.  For internal use."""
This patch aims to modify the last testcase instead of all of the previous. It solved the parsing bug which two or more testcases with the same name but different options caused.

     ACK and pushed.

     Guannan Ren


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]