From b8114b25ed28437248322aad50209f737faa392c Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 17 Nov 2010 13:37:03 -0500 Subject: 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. --- sleekxmpp/xmlstream/matcher/xmlmask.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'sleekxmpp/xmlstream/matcher') 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), -- cgit v1.2.3