mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Compatibility import for ElementTree
This commit is contained in:
parent
a8d258cefc
commit
008a1b7fc9
@ -11,6 +11,23 @@ try:
|
||||
import cPickle as pickle
|
||||
except ImportError:
|
||||
import pickle
|
||||
try:
|
||||
# Python >2.5
|
||||
import xml.etree.cElementTree as ElementTree
|
||||
except ImportError:
|
||||
try:
|
||||
# Python >2.5
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
except ImportError:
|
||||
try:
|
||||
# normal cElementTree install
|
||||
import cElementTree as ElementTree
|
||||
except ImportError:
|
||||
try:
|
||||
# normal ElementTree install
|
||||
import elementtree.ElementTree as ElementTree
|
||||
except ImportError:
|
||||
raise
|
||||
|
||||
|
||||
# True if we are running on Python 3.
|
||||
|
@ -12,7 +12,7 @@ ensure_in_syspath('../../')
|
||||
|
||||
# Import salt libs
|
||||
from salt.modules import virt
|
||||
from salt._compat import StringIO as _StringIO
|
||||
from salt._compat import StringIO as _StringIO, ElementTree as _ElementTree
|
||||
|
||||
virt.__salt__ = {}
|
||||
|
||||
@ -87,7 +87,7 @@ class VirtTestCase(TestCase):
|
||||
'esxi',
|
||||
eth1_mac='00:00:00:00:00:00',
|
||||
)
|
||||
tree = ElementTree.parse(_StringIO(xml_data))
|
||||
tree = _ElementTree.parse(_StringIO(xml_data))
|
||||
self.assertTrue(tree.getroot().attrib['type'] == 'vmware')
|
||||
self.assertTrue(tree.find('vcpu').text == '1')
|
||||
self.assertTrue(tree.find('memory').text == '524288')
|
||||
|
Loading…
Reference in New Issue
Block a user