[virt-tools-list] [virt-manager PATCH] tests: fix TestCapabilities.testCPUMap

Roman Bogorodskiy bogorodskiy at gmail.com
Fri Apr 4 17:13:20 UTC 2014


testCPUMap() tries to open /usr/share/libvirt/cpu_map.xml file
and that fails if libvirt is not installed on the system
or cpu_map.xml path is different.

Force it to use tests/capabilities-xml/cpu_map.xml file instead.
---
 tests/capabilities.py    | 2 ++
 virtinst/capabilities.py | 5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/capabilities.py b/tests/capabilities.py
index db69c6f..8c18993 100644
--- a/tests/capabilities.py
+++ b/tests/capabilities.py
@@ -20,6 +20,7 @@ import unittest
 
 from tests import utils
 from virtinst import CapabilitiesParser as capabilities
+from virtinst.capabilities import _CPUMapFileValues
 
 
 def build_host_feature_dict(feature_list):
@@ -221,6 +222,7 @@ class TestCapabilities(unittest.TestCase):
         test_utils(new_caps_no_kvm, False, True, False, False, False)
 
     def testCPUMap(self):
+        _CPUMapFileValues._cpu_filename = "tests/capabilities-xml/cpu_map.xml"
         caps = self._buildCaps("libvirt-0.7.6-qemu-caps.xml")
         cpu_64 = caps.get_cpu_values(None, "x86_64")
         cpu_32 = caps.get_cpu_values(None, "i486")
diff --git a/virtinst/capabilities.py b/virtinst/capabilities.py
index f5c28af..6955ec9 100644
--- a/virtinst/capabilities.py
+++ b/virtinst/capabilities.py
@@ -102,11 +102,12 @@ class _CPUMapFileValues(_CPUAPIValues):
     Fallback method to lists cpu models, parsed directly from libvirt's local
     cpu_map.xml
     """
+    _cpu_filename = "/usr/share/libvirt/cpu_map.xml"
+
     def __init__(self):
         _CPUAPIValues.__init__(self)
         self.archmap = {}
-        cpu_filename = "/usr/share/libvirt/cpu_map.xml"
-        xml = file(cpu_filename).read()
+        xml = file(self._cpu_filename).read()
 
         util.parse_node_helper(xml, "cpus",
                                 self._parseXML,
-- 
1.9.0




More information about the virt-tools-list mailing list