Change in vdsm[master]: tests: move find() helper into testlib
fromani at redhat.com
fromani at redhat.com
Wed Feb 25 08:02:31 UTC 2015
Francesco Romani has uploaded a new change for review.
Change subject: tests: move find() helper into testlib
......................................................................
tests: move find() helper into testlib
Recently the vmTests gained a find() helper
function to make xml tests less fragile,
allowing to assertXMLEqual() only the minimal
amount of XML.
This patch moves this helper into testlib,
to make it easily available to other test suites.
Only code moving and import fixing.
Change-Id: I6c09d49a33c9a6e617300190048a58d6cf2b0611
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M tests/testlib.py
M tests/vmTests.py
2 files changed, 18 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/38152/1
diff --git a/tests/testlib.py b/tests/testlib.py
index 4eb0247..ee272b0 100644
--- a/tests/testlib.py
+++ b/tests/testlib.py
@@ -269,6 +269,23 @@
(actualXML, expectedXML))
+def find(xml, match):
+ """
+ Finds the first element matching match. match may be a tag name or path.
+ Returns found element xml.
+
+ path is using the limmited supported xpath syntax:
+ https://docs.python.org/2/library/
+ xml.etree.elementtree.html#supported-xpath-syntax
+ Note that xpath support in Python 2.6 is partial and undocumented.
+ """
+ elem = ET.fromstring(xml)
+ found = elem.find(match)
+ if found is None:
+ raise AssertionError("No such element: %s" % match)
+ return ET.tostring(found)
+
+
def indent(elem, level=0, s=" "):
"""
Modify elem indentation in-place.
diff --git a/tests/vmTests.py b/tests/vmTests.py
index cb55c31..26023d2 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -23,7 +23,6 @@
import re
import threading
import time
-import xml.etree.ElementTree as ET
import uuid
import libvirt
@@ -39,6 +38,7 @@
from vdsm import define
from testlib import VdsmTestCase as TestCaseBase
from testlib import permutations, expandPermutations
+from testlib import find
from testlib import make_config
from testlib import XMLTestCase
import caps
@@ -53,23 +53,6 @@
import vmfakelib as fake
from testValidation import slowtest
-
-
-def find(xml, match):
- """
- Finds the first element matching match. match may be a tag name or path.
- Returns found element xml.
-
- path is using the limmited supported xpath syntax:
- https://docs.python.org/2/library/
- xml.etree.elementtree.html#supported-xpath-syntax
- Note that xpath support in Python 2.6 is partial and undocumented.
- """
- elem = ET.fromstring(xml)
- found = elem.find(match)
- if found is None:
- raise AssertionError("No such element: %s" % match)
- return ET.tostring(found)
class TestVm(XMLTestCase):
--
To view, visit https://gerrit.ovirt.org/38152
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c09d49a33c9a6e617300190048a58d6cf2b0611
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
More information about the vdsm-patches
mailing list