summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/utils.py19
-rw-r--r--virtinst/uri.py6
2 files changed, 5 insertions, 20 deletions
diff --git a/tests/utils.py b/tests/utils.py
index 95d2e549..748e8084 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -23,6 +23,7 @@ import libvirt
import virtinst
import virtinst.cli
+import virtinst.uri
# DON'T EDIT THIS. Use 'setup.py test --regenerate-output'
REGENERATE_OUTPUT = False
@@ -144,24 +145,8 @@ def _libvirt_callback(ignore, err):
libvirt.registerErrorHandler(f=_libvirt_callback, ctx=None)
-def sanitize_xml_for_define(xml):
- # Libvirt throws errors since we are defining domain
- # type='xen', when test driver can only handle type='test'
- # Sanitize the XML so we can define
- if not xml:
- return xml
-
- xml = xml.replace(">linux<", ">xen<")
- for t in ["xen", "qemu", "kvm"]:
- xml = xml.replace("<domain type=\"%s\">" % t,
- "<domain type=\"test\">")
- xml = xml.replace("<domain type='%s'>" % t,
- "<domain type='test'>")
- return xml
-
-
def test_create(testconn, xml, define_func="defineXML"):
- xml = sanitize_xml_for_define(xml)
+ xml = virtinst.uri.sanitize_xml_for_test_define(xml)
try:
func = getattr(testconn, define_func)
diff --git a/virtinst/uri.py b/virtinst/uri.py
index 9ab101d4..e4cda2e8 100644
--- a/virtinst/uri.py
+++ b/virtinst/uri.py
@@ -23,7 +23,7 @@ import re
from .cli import VirtOptionString
-def _sanitize_xml(xml):
+def sanitize_xml_for_test_define(xml):
import difflib
orig = xml
@@ -221,10 +221,10 @@ class MagicURI(object):
origcreate = conn.createLinux
origdefine = conn.defineXML
def newcreate(xml, flags):
- xml = _sanitize_xml(xml)
+ xml = sanitize_xml_for_test_define(xml)
return origcreate(xml, flags)
def newdefine(xml):
- xml = _sanitize_xml(xml)
+ xml = sanitize_xml_for_test_define(xml)
return origdefine(xml)
conn.createLinux = newcreate
conn.defineXML = newdefine