示例#1
0
 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)))
示例#2
0
 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)))
示例#3
0
 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])
示例#4
0
 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))
示例#6
0
 def __str__(self):
     if self._is_instance:
         return "MatchesException(%s)" % _error_repr(self.expected)
     return "MatchesException(%s)" % repr(self.expected)
示例#7
0
 def __str__(self):
     if self._is_instance:
         return "MatchesException(%s)" % _error_repr(self.expected)
     return "MatchesException(%s)" % repr(self.expected)