How to use _exc_info_to_string method in unittest-xml-reporting

Best Python code snippet using unittest-xml-reporting_python

result.py

Source:result.py Github

copy

Full Screen

...39 """40 stream = getattr(self, 'stream', None)41 ec, ev, tb = err42 try:43 exc_info = self._exc_info_to_string(err, test)44 except TypeError:45 # 2.3 compat46 exc_info = self._exc_info_to_string(err)47 for cls, (storage, label, isfail) in self.errorClasses.items():48 if isclass(ec) and issubclass(ec, cls):49 if isfail:50 test.passed = False51 storage.append((test, exc_info))52 # Might get patched into a streamless result53 if stream is not None:54 if self.showAll:55 message = [label]56 detail = _exception_detail(err[1])57 if detail:58 message.append(detail)59 stream.writeln(": ".join(message))60 elif self.dots:61 stream.write(label[:1])62 return63 self.errors.append((test, exc_info))64 test.passed = False65 if stream is not None:66 if self.showAll:67 self.stream.writeln('ERROR')68 elif self.dots:69 stream.write('E')70 def printErrors(self):71 """Overrides to print all errorClasses errors as well.72 """73 _TextTestResult.printErrors(self)74 for cls in self.errorClasses.keys():75 storage, label, isfail = self.errorClasses[cls]76 if isfail:77 self.printErrorList(label, storage)78 # Might get patched into a result with no config79 if hasattr(self, 'config'):80 self.config.plugins.report(self.stream)81 def printSummary(self, start, stop):82 """Called by the test runner to print the final summary of test83 run results.84 """85 write = self.stream.write86 writeln = self.stream.writeln87 taken = float(stop - start)88 run = self.testsRun89 plural = run != 1 and "s" or ""90 91 writeln(self.separator2)92 writeln("Ran %s test%s in %.3fs" % (run, plural, taken))93 writeln()94 summary = {}95 eckeys = self.errorClasses.keys()96 eckeys.sort()97 for cls in eckeys:98 storage, label, isfail = self.errorClasses[cls]99 count = len(storage)100 if not count:101 continue102 summary[label] = count103 if len(self.failures):104 summary['failures'] = len(self.failures)105 if len(self.errors):106 summary['errors'] = len(self.errors)107 if not self.wasSuccessful():108 write("FAILED")109 else:110 write("OK")111 items = summary.items()112 if items:113 items.sort()114 write(" (")115 write(", ".join(["%s=%s" % (label, count) for116 label, count in items]))117 writeln(")")118 else:119 writeln()120 def wasSuccessful(self):121 """Overrides to check that there are no errors in errorClasses122 lists that are marked as errors and should cause a run to123 fail.124 """125 if self.errors or self.failures:126 return False127 for cls in self.errorClasses.keys():128 storage, label, isfail = self.errorClasses[cls]129 if not isfail:130 continue131 if storage:132 return False133 return True134 def _addError(self, test, err):135 try:136 exc_info = self._exc_info_to_string(err, test)137 except TypeError:138 # 2.3: does not take test arg139 exc_info = self._exc_info_to_string(err)140 self.errors.append((test, exc_info))141 if self.showAll:142 self.stream.write('ERROR')143 elif self.dots:144 self.stream.write('E')145 def _exc_info_to_string(self, err, test=None):146 # 2.3/2.4 -- 2.4 passes test, 2.3 does not147 try:148 return _TextTestResult._exc_info_to_string(self, err, test)149 except TypeError:150 # 2.3: does not take test arg151 return _TextTestResult._exc_info_to_string(self, err)152def ln(*arg, **kw):153 from warnings import warn154 warn("ln() has moved to nose.util from nose.result and will be removed "155 "from nose.result in a future release. Please update your imports ",156 DeprecationWarning)157 return _ln(*arg, **kw)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run unittest-xml-reporting automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful