Fix bug when comparing lists.

zip is used to compare corresponding items from each list.
But zip of unequal length lists justs zips the shortest length.
For example, zip([], [1,2]) yields []. This is not what you want.
So I make sure the lists are the same length before the zip.

I doscivered this when comparing 2 dicts which becomes a list comparison
of keys...

Signed-off-by: John Fodor <[email protected]>

--- autotest/client/common_lib/test_utils/mock.py       2010-03-23 
14:17:36.000000000 -0700
+++ autotest/client/common_lib/test_utils/mock.py       2010-03-23 
14:17:36.000000000 -0700
@@ -58,6 +58,8 @@
 
         if isinstance(expected_arg, list) or isinstance(expected_arg, tuple):
             # recurse on lists/tuples
+            if len(actual_arg) != len(expected_arg):
+                return False
             for actual_item, expected_item in zip(actual_arg, expected_arg):
                 if not cls._compare(actual_item, expected_item):
                     return False
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to