def notfind_in(self, what, where, flags='', flat=False, escape=False): """ Alternate version of ``notfind`` method that allow to check that text not found in another text, not only in current loaded page. ``notfind_in`` supports all keywords from original ``notfind`` method. If ``what`` found in ``where``, ``notfind_in`` raises ``TwillAssertionError``. """ found = False if escape: what = real_escape(what) if flat and what in where: found = True elif not flat: regexp = re.compile(what, _parseFindFlags(flags)) if regexp.search(where): found = True if found: self.text_to_twill(where) raise TwillAssertionError('Match to %r' % what) return True
def find_in(self, what, where, flags='', flat=False, count=None, escape=False): """ Alternate version of ``find`` method that allow to find text in another text, not only in current loaded page. ``find_in`` supports all keywords from original ``find`` method. If ``what`` not found in ``where``, ``find_in`` raises ``TwillAssertionError``. """ if escape: what = real_escape(what) if not flat and not count: regexp = re.compile(what, _parseFindFlags(flags)) if not regexp.search(where): self.text_to_twill(where) raise TwillAssertionError('No match to %r' % what) return True real_count = where.count(what) if count is not None and count != real_count: self.text_to_twill(where) raise TwillAssertionError('Matched to %r %d times, not %d ' \ 'times.' % (what, real_count, count)) elif real_count == 0: self.text_to_twill(where) raise TwillAssertionError('No match to %r' % what) return True