summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-04-22 23:40:50 -0700
committerNathan Fritz <nathan@andyet.net>2010-04-22 23:40:50 -0700
commite2f841146aba29abf4b99157bb5479c2356f89c5 (patch)
treee40f9d97a4abd38132f7f708d84a6b9c26cce636 /tests
parent602a6d8491171de5cccb332684813e71f5d33c43 (diff)
downloadslixmpp-e2f841146aba29abf4b99157bb5479c2356f89c5.tar.gz
slixmpp-e2f841146aba29abf4b99157bb5479c2356f89c5.tar.bz2
slixmpp-e2f841146aba29abf4b99157bb5479c2356f89c5.tar.xz
slixmpp-e2f841146aba29abf4b99157bb5479c2356f89c5.zip
forgot to add file required to pass testall.py
Diffstat (limited to 'tests')
-rw-r--r--tests/xmlcompare.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/xmlcompare.py b/tests/xmlcompare.py
new file mode 100644
index 00000000..d97af971
--- /dev/null
+++ b/tests/xmlcompare.py
@@ -0,0 +1,28 @@
+from xml.etree import cElementTree as ET
+
+def comparemany(xmls):
+ xml1 = xmls[0]
+ if type(xml1) == type(''):
+ xml1 = ET.fromstring(xml1)
+ for xml in xmls[1:]:
+ xml2 = xml
+ if type(xml2) == type(''):
+ xml2 = ET.fromstring(xml2)
+ if not compare(xml1, xml2): return False
+ return True
+
+def compare(xml1, xml2):
+ if xml1.tag != xml2.tag:
+ return False
+ if xml1.attrib != xml2.attrib:
+ return False
+ for child in xml1:
+ child2s = xml2.findall("%s" % child.tag)
+ if child2s is None:
+ return False
+ found = False
+ for child2 in child2s:
+ found = compare(child, child2)
+ if found: break
+ if not found: return False
+ return True