Esempio n. 1
0
 def __init__(self, exc_info=None, **kwargs):
     if not kwargs:
         if exc_info is None:
             exc_info = sys.exc_info()
         else:
             # This should always be the (type, value, traceback) tuple,
             # either from a prior sys.exc_info() call or from some other
             # creation...
             if len(exc_info) != 3:
                 raise ValueError("Provided 'exc_info' must contain three"
                                  " elements")
         self._exc_info = exc_info
         self._exc_type_names = tuple(
             reflection.get_all_class_names(exc_info[0], up_to=Exception))
         if not self._exc_type_names:
             raise TypeError('Invalid exception type: %r' % exc_info[0])
         self._exception_str = exc.exception_message(self._exc_info[1])
         self._traceback_str = ''.join(
             traceback.format_tb(self._exc_info[2]))
     else:
         self._exc_info = exc_info  # may be None
         self._exception_str = kwargs.pop('exception_str')
         self._exc_type_names = tuple(kwargs.pop('exc_type_names', []))
         self._traceback_str = kwargs.pop('traceback_str', None)
         if kwargs:
             raise TypeError(
                 'Failure.__init__ got unexpected keyword argument(s): %s'
                 % ', '.join(six.iterkeys(kwargs)))
Esempio n. 2
0
 def __init__(self, exc_info=None, **kwargs):
     if not kwargs:
         if exc_info is None:
             exc_info = sys.exc_info()
         self._exc_info = exc_info
         self._exc_type_names = list(
             reflection.get_all_class_names(exc_info[0], up_to=Exception))
         if not self._exc_type_names:
             raise TypeError('Invalid exception type: %r' % exc_info[0])
         self._exception_str = exc.exception_message(self._exc_info[1])
         self._traceback_str = ''.join(
             traceback.format_tb(self._exc_info[2]))
     else:
         self._exc_info = exc_info  # may be None
         self._exception_str = kwargs.pop('exception_str')
         self._exc_type_names = kwargs.pop('exc_type_names', [])
         self._traceback_str = kwargs.pop('traceback_str', None)
         if kwargs:
             raise TypeError(
                 'Failure.__init__ got unexpected keyword argument(s): %s'
                 % ', '.join(six.iterkeys(kwargs)))
Esempio n. 3
0
 def __init__(self, exc_info=None, **kwargs):
     if not kwargs:
         if exc_info is None:
             exc_info = sys.exc_info()
         self._exc_info = exc_info
         self._exc_type_names = list(
             reflection.get_all_class_names(exc_info[0], up_to=Exception))
         if not self._exc_type_names:
             raise TypeError('Invalid exception type: %r' % exc_info[0])
         self._exception_str = str(self._exc_info[1])
         self._traceback_str = ''.join(
             traceback.format_tb(self._exc_info[2]))
     else:
         self._exc_info = exc_info  # may be None
         self._exception_str = kwargs.pop('exception_str')
         self._exc_type_names = kwargs.pop('exc_type_names', [])
         self._traceback_str = kwargs.pop('traceback_str', None)
         if kwargs:
             raise TypeError(
                 'Failure.__init__ got unexpected keyword argument(s): %s'
                 % ', '.join(six.iterkeys(kwargs)))
Esempio n. 4
0
 def test_std_class_up_to(self):
     names = list(reflection.get_all_class_names(RuntimeError,
                                                 up_to=Exception))
     self.assertEqual(names, test_utils.RUNTIME_ERROR_CLASSES[:-2])
Esempio n. 5
0
 def test_std_class(self):
     names = list(reflection.get_all_class_names(RuntimeError))
     self.assertEqual(names, test_utils.RUNTIME_ERROR_CLASSES)
Esempio n. 6
0
 def test_std_class_up_to(self):
     names = list(
         reflection.get_all_class_names(RuntimeError, up_to=Exception))
     self.assertEquals(names, test_utils.RUNTIME_ERROR_CLASSES[:-2])
Esempio n. 7
0
 def test_std_class(self):
     names = list(reflection.get_all_class_names(RuntimeError))
     self.assertEquals(names, test_utils.RUNTIME_ERROR_CLASSES)