def __exit__(self, exc_type, exc_value, traceback): if exc_type is None: raise AssertionError("%s not raised." % self.exc_type.__name__) if exc_type != self.exc_type: return False if self.value_re: matcher = MatchesException(self.exc_type, self.value_re) mismatch = matcher.match((exc_type, exc_value, traceback)) if mismatch: raise AssertionError(mismatch.describe()) return True
def __exit__(self, exc_type, exc_value, traceback): if exc_type is None: raise AssertionError('%s not raised.' % self.exc_type.__name__) if exc_type != self.exc_type: return False if self.value_re: matcher = MatchesException(self.exc_type, self.value_re) mismatch = matcher.match((exc_type, exc_value, traceback)) if mismatch: raise AssertionError(mismatch.describe()) return True
def __exit__(self, exc_type, exc_value, traceback): if exc_type is None: error_msg = '%s not raised.' % self.exc_type.__name__ if self.msg: error_msg = error_msg + ' : ' + self.msg raise AssertionError(error_msg) if exc_type != self.exc_type: return False if self.value_re: matcher = MatchesException(self.exc_type, self.value_re) if self.msg: matcher = Annotate(self.msg, matcher) mismatch = matcher.match((exc_type, exc_value, traceback)) if mismatch: raise AssertionError(mismatch.describe()) return True
def __eq__(self, other): matcher = MatchesException(self.exception) return ( isinstance(other, Failure) and other.check(type(self.exception)) is not None and matcher.match((type(other.value), other.value, None)) is None)