예제 #1
0
 def match(self, call_tuple):
     for k, v in self._filters.items():
         try:
             pos = self._position_lookup[k]
             if call_tuple[pos] != v:
                 return matchers.Mismatch("Value for key is %r, not %r" %
                                          (call_tuple[pos], v))
         except IndexError:
             return matchers.Mismatch("Key %s is not present." % k)
예제 #2
0
 def match(self, failure):
     for cause in failure:
         if cause.check(self.exc_class) is not None:
             return matchers.MatchesRegex(self.pattern).match(
                 cause.exception_str)
     return matchers.Mismatch("The `%s` wasn't caused by the `%s`" %
                              (failure, self.exc_class))
예제 #3
0
    def match(self, actual):
        if len(actual) != 1:
            return matchers.Mismatch("Response contains <> 1 item: %r" % actual)

        response_data = json.loads(actual[0])

        if u"links" in response_data:
            del response_data[u"links"]

        return matchers.Equals(self.expected_data).match(response_data)
예제 #4
0
 def match(self, other):
     other_list = list(other)
     extra = misc.sequence_minus(other_list, self._list)
     missing = misc.sequence_minus(self._list, other_list)
     if extra or missing:
         msg = ("Sequences %s and %s do not have same items." %
                (self._seq, other))
         if missing:
             msg += " Extra items in first sequence: %s." % missing
         if extra:
             msg += " Extra items in second sequence: %s." % extra
         return matchers.Mismatch(msg)
     return None
예제 #5
0
 def match(self, other):
     if other >= self.source:
         return None
     return matchers.Mismatch("%s was not >= %s" % (other, self.source))