Exemple #1
0
 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
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 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
Exemple #5
0
 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)
Exemple #6
0
 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)