From 7301258b16ebb82ecc9bd91d9e315fa4989f9942 Mon Sep 17 00:00:00 2001 From: Haotong Chen Date: Thu, 12 Oct 2017 16:09:58 +0800 Subject: [PATCH] usb_common:changed imports Modified imported modules to make it compatible with both python 2.6 and 2.7 Signed-off-by: Haotong Chen --- qemu/tests/usb_common.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qemu/tests/usb_common.py b/qemu/tests/usb_common.py index d22b941e..76b012c0 100644 --- a/qemu/tests/usb_common.py +++ b/qemu/tests/usb_common.py @@ -1,6 +1,9 @@ -import json +try: + import simplejson as json +except ImportError: + import json -from collections import OrderedDict, Counter +from collections import OrderedDict from virttest import utils_misc @@ -106,8 +109,9 @@ def verify_usb_device_in_guest(params, session, devs): if dev[1] not in output: return False # match number of devices - counter = Counter(dev[1] for dev in devs) - for k, v in counter.items(): + dev_list = [dev[1] for dev in devs] + dev_nums = dict((i, dev_list.count(i)) for i in dev_list) + for k, v in dev_nums.items(): if output.count(k) != v: return False return True -- GitLab