summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-11-17 13:37:03 -0500
committerLance Stout <lancestout@gmail.com>2010-11-17 13:43:15 -0500
commitb8114b25ed28437248322aad50209f737faa392c (patch)
tree998512dd09883dd08a6facf0ae71ac0c3ba5be03 /sleekxmpp/xmlstream
parent45991e47eeab97f0411139c5b1627ac6350de3d0 (diff)
downloadslixmpp-b8114b25ed28437248322aad50209f737faa392c.tar.gz
slixmpp-b8114b25ed28437248322aad50209f737faa392c.tar.bz2
slixmpp-b8114b25ed28437248322aad50209f737faa392c.tar.xz
slixmpp-b8114b25ed28437248322aad50209f737faa392c.zip
Make live stream tests work better.
SleekTest can now use matchers when checking stanzas, using the method parameter for self.check(), self.recv(), and self.send(): method='exact' - Same behavior as before 'xpath' - Use xpath matcher 'id' - Use ID matcher 'mask' - Use XML mask matcher 'stanzapath' - Use StanzaPath matcher recv_feature and send_feature only accept 'exact' and 'mask' for now.
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r--sleekxmpp/xmlstream/matcher/xmlmask.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/sleekxmpp/xmlstream/matcher/xmlmask.py b/sleekxmpp/xmlstream/matcher/xmlmask.py
index 6ebb437d..60e19495 100644
--- a/sleekxmpp/xmlstream/matcher/xmlmask.py
+++ b/sleekxmpp/xmlstream/matcher/xmlmask.py
@@ -117,7 +117,7 @@ class MatchXMLMask(MatcherBase):
return False
# If the mask includes text, compare it.
- if mask.text and source.text != mask.text:
+ if mask.text and source.text and source.text.strip() != mask.text.strip():
return False
# Compare attributes. The stanza must include the attributes
@@ -127,10 +127,17 @@ class MatchXMLMask(MatcherBase):
return False
# Recursively check subelements.
+ matched_elements = {}
for subelement in mask:
if use_ns:
- if not self._mask_cmp(source.find(subelement.tag),
- subelement, use_ns):
+ matched = False
+ for other in source.findall(subelement.tag):
+ matched_elements[other] = False
+ if self._mask_cmp(other, subelement, use_ns):
+ if not matched_elements.get(other, False):
+ matched_elements[other] = True
+ matched = True
+ if not matched:
return False
else:
if not self._mask_cmp(self._get_child(source, subelement.tag),