Exemplo n.º 1
0
 def addError(self, test, err):
     """Overrides normal addError to add support for
     errorClasses. If the exception is a registered class, the
     error will be added to the list for that class, not errors.
     """
     self._handleElapsedTime(test)
     stream = getattr(self, 'stream', None)
     ec, ev, tb = err
     try:
         exc_info = self._exc_info_to_string(err, test)
     except TypeError:
         # 2.3 compat
         exc_info = self._exc_info_to_string(err)
     for cls, (storage, label, isfail) in self.errorClasses.items():
         if result.isclass(ec) and issubclass(ec, cls):
             if isfail:
                 test.passed = False
             storage.append((test, exc_info))
             # Might get patched into a streamless result
             if stream is not None:
                 if self.showAll:
                     message = [label]
                     detail = result._exception_detail(err[1])
                     if detail:
                         message.append(detail)
                     stream.writeln(": ".join(message))
                 elif self.dots:
                     stream.write(label[:1])
             return
     self.errors.append((test, exc_info))
     test.passed = False
     if stream is not None:
         self._writeResult(test, 'ERROR', 'red', 'E', False)
Exemplo n.º 2
0
 def addError(self, test, err):
     """Overrides normal addError to add support for
     errorClasses. If the exception is a registered class, the
     error will be added to the list for that class, not errors.
     """
     self._handleElapsedTime(test)
     stream = getattr(self, 'stream', None)
     ec, ev, tb = err
     try:
         exc_info = self._exc_info_to_string(err, test)
     except TypeError:
         # 2.3 compat
         exc_info = self._exc_info_to_string(err)
     for cls, (storage, label, isfail) in self.errorClasses.items():
         if result.isclass(ec) and issubclass(ec, cls):
             if isfail:
                 test.passed = False
             storage.append((test, exc_info))
             # Might get patched into a streamless result
             if stream is not None:
                 if self.showAll:
                     message = [label]
                     detail = result._exception_detail(err[1])
                     if detail:
                         message.append(detail)
                     stream.writeln(": ".join(message))
                 elif self.dots:
                     stream.write(label[:1])
             return
     self.errors.append((test, exc_info))
     test.passed = False
     if stream is not None:
         self._writeResult(test, 'ERROR', 'red', 'E', False)
Exemplo n.º 3
0
 def addError(self, test, err):
     stream = getattr(self, 'stream', None)
     ec, ev, tb = err
     try:
         exc_info = self._exc_info_to_string(err, test)
     except TypeError:
         # 2.3 compat
         exc_info = self._exc_info_to_string(err)
     for cls, (storage, label, isfail) in self.errorClasses.items():
         if result.isclass(ec) and issubclass(ec, cls):
             if isfail:
                 test.passed = False
             storage.append((test, exc_info))
             # Might get patched into a streamless result
             if stream is not None:
                 if self.showAll:
                     message = [label]
                     detail = result._exception_detail(err[1])
                     if detail:
                         message.append(detail)
                     stream.writeln(": ".join(message))
                 elif self.dots:
                     stream.write(label[:1])
             return
     self.errors.append((test, exc_info))
     test.passed = False
     if stream is not None:
         self._writeResult(test, 'ERROR', TermColor.red, 'E', False)
Exemplo n.º 4
0
 def addError(self, test, err):
     stream = getattr(self, 'stream', None)
     ec, ev, tb = err
     try:
         exc_info = self._exc_info_to_string(err, test)
     except TypeError:
         # 2.3 compat
         exc_info = self._exc_info_to_string(err)
     for cls, (storage, label, isfail) in self.errorClasses.items():
         if result.isclass(ec) and issubclass(ec, cls):
             if isfail:
                 test.passed = False
             storage.append((test, exc_info))
             # Might get patched into a streamless result
             if stream is not None:
                 if self.showAll:
                     message = [label]
                     detail = result._exception_detail(err[1])
                     if detail:
                         message.append(detail)
                     stream.writeln(": ".join(message))
                 elif self.dots:
                     stream.write(label[:1])
             return
     self.errors.append((test, exc_info))
     test.passed = False
     if stream is not None:
         self._writeResult(test, 'ERROR', TermColor.red, 'E', False)
Exemplo n.º 5
0
 def addError(self, test, err):
     """Overrides normal addError to add support for errorClasses.
     If the exception is a registered class, the error will be added
     to the list for that class, not errors.
     """
     stream = getattr(self, "stream", None)
     ec, ev, tb = err
     try:
         exc_info = self._exc_info_to_string(err, test)
     except TypeError:
         # This is for compatibility with Python 2.3.
         exc_info = self._exc_info_to_string(err)
     for cls, (storage, label, isfail) in self.errorClasses.items():
         if result.isclass(ec) and issubclass(ec, cls):
             if isfail:
                 test.passwd = False
             storage.append((test, exc_info))
             # Might get patched into a streamless result
             if stream is not None:
                 if self.showAll:
                     message = [label]
                     detail = result._exception_details(err[1])
                     if detail:
                         message.append(detail)
                     stream.writeln(": ".join(message))
                 elif self.dots:
                     stream.write(label[:1])
             return
     self.errors.append((test, exc_info))
     test.passed = False
     if stream is not None:
         if self.showAll:
             self.colorizer.write("ERROR", "red")
             self.stream.writeln()
         elif self.dots:
             stream.write("E")