mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-08-06 21:49:26 +03:00
sanitytest.py parameters are now optional
When called without parameters, sanitytest.py doesn't touch sys.path and locates itself the patch to the libvirt-api.xml file using pkg-config. This change makes possible to run sanitytest.py from tox.
This commit is contained in:
committed by
Daniel P. Berrange
parent
cd2d02ab0d
commit
4e7a8bd3b3
@ -5,18 +5,31 @@ import lxml
|
|||||||
import lxml.etree
|
import lxml.etree
|
||||||
import string
|
import string
|
||||||
|
|
||||||
# Munge import path to insert build location for libvirt mod
|
if len(sys.argv) >= 2:
|
||||||
sys.path.insert(0, sys.argv[1])
|
# Munge import path to insert build location for libvirt mod
|
||||||
|
sys.path.insert(0, sys.argv[1])
|
||||||
import libvirt
|
import libvirt
|
||||||
|
|
||||||
if sys.version > '3':
|
if sys.version > '3':
|
||||||
long = int
|
long = int
|
||||||
|
|
||||||
# Path to the libvirt API XML file
|
def get_libvirt_api_xml_path():
|
||||||
xml = sys.argv[2]
|
import subprocess
|
||||||
|
args = ["pkg-config", "--variable", "libvirt_api", "libvirt"]
|
||||||
|
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||||
|
stdout, _ = proc.communicate()
|
||||||
|
if proc.returncode:
|
||||||
|
sys.exit(proc.returncode)
|
||||||
|
return stdout.splitlines()[0]
|
||||||
|
|
||||||
f = open(xml, "r")
|
# Path to the libvirt API XML file
|
||||||
tree = lxml.etree.parse(f)
|
if len(sys.argv) >= 3:
|
||||||
|
xml = sys.argv[2]
|
||||||
|
else:
|
||||||
|
xml = get_libvirt_api_xml_path()
|
||||||
|
|
||||||
|
with open(xml, "r") as fp:
|
||||||
|
tree = lxml.etree.parse(fp)
|
||||||
|
|
||||||
verbose = False
|
verbose = False
|
||||||
fail = False
|
fail = False
|
||||||
|
Reference in New Issue
Block a user