diff options
author | mathieui <mathieui@mathieui.net> | 2021-02-20 11:27:33 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-02-20 11:27:33 +0100 |
commit | 2f0660c6ffc39639739fb6c0adfaa555e5780a73 (patch) | |
tree | e8f8b652574594f178e056172861a3f8167e0d89 | |
parent | 2ba89727a6627f86e66ec4f3baba464da1b0b19c (diff) | |
parent | ba7e5e417f23f5c25ac079293fa4a2136c441a02 (diff) | |
download | slixmpp-2f0660c6ffc39639739fb6c0adfaa555e5780a73.tar.gz slixmpp-2f0660c6ffc39639739fb6c0adfaa555e5780a73.tar.bz2 slixmpp-2f0660c6ffc39639739fb6c0adfaa555e5780a73.tar.xz slixmpp-2f0660c6ffc39639739fb6c0adfaa555e5780a73.zip |
Merge branch 'fix-slixtest-default-ns-component' into 'master'
slixtest: use the default stream ns instead of jabber:client
See merge request poezio/slixmpp!133
-rw-r--r-- | slixmpp/test/slixtest.py | 19 |
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) |