summaryrefslogtreecommitdiff
path: root/slixmpp/test/slixtest.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-02-17 19:40:56 +0100
committermathieui <mathieui@mathieui.net>2021-02-20 11:24:43 +0100
commitba7e5e417f23f5c25ac079293fa4a2136c441a02 (patch)
treee8f8b652574594f178e056172861a3f8167e0d89 /slixmpp/test/slixtest.py
parent2ba89727a6627f86e66ec4f3baba464da1b0b19c (diff)
downloadslixmpp-ba7e5e417f23f5c25ac079293fa4a2136c441a02.tar.gz
slixmpp-ba7e5e417f23f5c25ac079293fa4a2136c441a02.tar.bz2
slixmpp-ba7e5e417f23f5c25ac079293fa4a2136c441a02.tar.xz
slixmpp-ba7e5e417f23f5c25ac079293fa4a2136c441a02.zip
slixtest: use the default stream ns instead of jabber:client
Diffstat (limited to 'slixmpp/test/slixtest.py')
-rw-r--r--slixmpp/test/slixtest.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/slixmpp/test/slixtest.py b/slixmpp/test/slixtest.py
index 6ae2cc8f..668b02c0 100644
--- a/slixmpp/test/slixtest.py
+++ b/slixmpp/test/slixtest.py
@@ -225,6 +225,10 @@ class SlixTest(unittest.TestCase):
"Stanza:\n%s" % str(stanza))
else:
stanza_class = stanza.__class__
+ # Hack to preserve namespaces instead of having jabber:client
+ # everywhere.
+ old_ns = stanza_class.namespace
+ stanza_class.namespace =stanza.namespace
if not isinstance(criteria, ElementBase):
xml = self.parse_xml(criteria)
else:
@@ -232,8 +236,8 @@ class SlixTest(unittest.TestCase):
# Ensure that top level namespaces are used, even if they
# were not provided.
- self.fix_namespaces(stanza.xml, 'jabber:client')
- self.fix_namespaces(xml, 'jabber:client')
+ self.fix_namespaces(stanza.xml)
+ self.fix_namespaces(xml)
stanza2 = stanza_class(xml=xml)
@@ -276,6 +280,7 @@ class SlixTest(unittest.TestCase):
debug += "Given stanza:\n%s\n" % highlight(tostring(stanza.xml))
debug += "Generated stanza:\n%s\n" % highlight(tostring(stanza2.xml))
result = self.compare(xml, stanza.xml, stanza2.xml)
+ stanza_class.namespace = old_ns
self.assertTrue(result, debug)
@@ -607,8 +612,8 @@ class SlixTest(unittest.TestCase):
self.fail("No stanza was sent.")
xml = self.parse_xml(sent)
- self.fix_namespaces(xml, 'jabber:client')
- sent = self.xmpp._build_stanza(xml, 'jabber:client')
+ self.fix_namespaces(xml)
+ sent = self.xmpp._build_stanza(xml)
self.check(sent, data,
method=method,
defaults=defaults,
@@ -638,7 +643,7 @@ class SlixTest(unittest.TestCase):
# ------------------------------------------------------------------
# XML Comparison and Cleanup
- def fix_namespaces(self, xml, ns):
+ def fix_namespaces(self, xml, ns=None):
"""
Assign a namespace to an element and any children that
don't have a namespace.
@@ -647,6 +652,10 @@ class SlixTest(unittest.TestCase):
xml -- The XML object to fix.
ns -- The namespace to add to the XML object.
"""
+ if ns is None:
+ ns = 'jabber:client'
+ if self.xmpp:
+ ns = self.xmpp.default_ns
if xml.tag.startswith('{'):
return
xml.tag = '{%s}%s' % (ns, xml.tag)