def match(self, other): if type(other) != tuple: return Mismatch('%r is not an exc_info tuple' % other) expected_class = self.expected if self._is_instance: expected_class = expected_class.__class__ if not issubclass(other[0], expected_class): return Mismatch('%r is not a %r' % (other[0], expected_class)) if self._is_instance and other[1].args != self.expected.args: return Mismatch('%s has different arguments to %s.' % ( _error_repr(other[1]), _error_repr(self.expected)))
def match(self, other): if type(other) != tuple: return Mismatch('%r is not an exc_info tuple' % other) expected_class = self.expected if self._is_instance: expected_class = expected_class.__class__ if not issubclass(other[0], expected_class): return Mismatch('%r is not a %r' % (other[0], expected_class)) if self._is_instance and other[1].args != self.expected.args: return Mismatch( '%s has different arguments to %s.' % (_error_repr(other[1]), _error_repr(self.expected)))
def match(self, other): if type(other) != tuple: return Mismatch("%r is not an exc_info tuple" % other) expected_class = self.expected if self._is_instance: expected_class = expected_class.__class__ if not issubclass(other[0], expected_class): return Mismatch("%r is not a %r" % (other[0], expected_class)) if self._is_instance: if other[1].args != self.expected.args: return Mismatch( "%s has different arguments to %s." % (_error_repr(other[1]), _error_repr(self.expected)) ) elif self.value_re is not None: return self.value_re.match(other[1])
def match(self, other): if type(other) != tuple: return Mismatch('%r is not an exc_info tuple' % other) expected_class = self.expected if self._is_instance: expected_class = expected_class.__class__ if not issubclass(other[0], expected_class): return Mismatch('%r is not a %r' % (other[0], expected_class)) if self._is_instance: if other[1].args != self.expected.args: return Mismatch( '%s has different arguments to %s.' % (_error_repr(other[1]), _error_repr(self.expected))) elif self.value_re is not None: str_exc_value = str(other[1]) if not re.match(self.value_re, str_exc_value): return Mismatch('"%s" does not match "%s".' % (str_exc_value, self.value_re))
def match(self, other): if type(other) != tuple: return Mismatch('%r is not an exc_info tuple' % other) expected_class = self.expected if self._is_instance: expected_class = expected_class.__class__ if not issubclass(other[0], expected_class): return Mismatch('%r is not a %r' % (other[0], expected_class)) if self._is_instance: if other[1].args != self.expected.args: return Mismatch('%s has different arguments to %s.' % ( _error_repr(other[1]), _error_repr(self.expected))) elif self.value_re is not None: str_exc_value = str(other[1]) if not re.match(self.value_re, str_exc_value): return Mismatch( '"%s" does not match "%s".' % (str_exc_value, self.value_re))
def __str__(self): if self._is_instance: return "MatchesException(%s)" % _error_repr(self.expected) return "MatchesException(%s)" % repr(self.expected)