Esempio n. 1
0
 def match(self, matchee):
     try:
         result = matchee()
         return Mismatch('%r returned %r' % (matchee, result))
     # Catch all exceptions: Raises() should be able to match a
     # KeyboardInterrupt or SystemExit.
     except:
         if self.exception_matcher:
             mismatch = self.exception_matcher.match(sys.exc_info())
             if not mismatch:
                 return
         else:
             mismatch = None
         # The exception did not match, or no explicit matching logic was
         # performed. If the exception is a non-user exception (that is, not
         # a subclass of Exception on Python 2.5+) then propogate it.
         if isbaseexception(sys.exc_info()[1]):
             raise
         return mismatch
Esempio n. 2
0
 def match(self, matchee):
     try:
         result = matchee()
         return Mismatch('%r returned %r' % (matchee, result))
     # Catch all exceptions: Raises() should be able to match a
     # KeyboardInterrupt or SystemExit.
     except:
         if self.exception_matcher:
             mismatch = self.exception_matcher.match(sys.exc_info())
             if not mismatch:
                 return
         else:
             mismatch = None
         # The exception did not match, or no explicit matching logic was
         # performed. If the exception is a non-user exception (that is, not
         # a subclass of Exception on Python 2.5+) then propogate it.
         if isbaseexception(sys.exc_info()[1]):
             raise
         return mismatch