Return a doctest-freindly traceback. Shows only the header, an ellipsis, and the excepttion line.
(
self,
etype,
evalue,
etb=None,
tb_offset=None,
context=5,
)
| 413 | return ListTB.structured_traceback(self, etype, value) |
| 414 | |
| 415 | def structured_traceback_doctest( |
| 416 | self, |
| 417 | etype, |
| 418 | evalue, |
| 419 | etb=None, |
| 420 | tb_offset=None, |
| 421 | context=5, |
| 422 | ): |
| 423 | """Return a doctest-freindly traceback. |
| 424 | |
| 425 | Shows only the header, an ellipsis, and the excepttion line. |
| 426 | """ |
| 427 | # Handle chained exception rule |
| 428 | if isinstance(etb, tuple): |
| 429 | etb, chained_exc_ids = etb |
| 430 | else: |
| 431 | chained_exc_ids = set() |
| 432 | |
| 433 | have_traceback = etb is not None |
| 434 | |
| 435 | out_list = [] |
| 436 | if have_traceback: |
| 437 | out_list.append("Traceback (most recent call last):\n") |
| 438 | out_list.append(" ...\n") |
| 439 | |
| 440 | lines = "".join(self._format_exception_only(etype, evalue)) |
| 441 | out_list.append(lines) |
| 442 | |
| 443 | # Handle chained exceptions |
| 444 | if etb is not None: |
| 445 | exception = self.get_parts_of_chained_exception(evalue) |
| 446 | if exception and (id(exception[1]) not in chained_exc_ids): |
| 447 | chained_exception_message = (self.prepare_chained_exception_message(evalue.__cause__)[0] if evalue is not None else [""]) |
| 448 | etype, evalue, etb = exception |
| 449 | chained_exc_ids.add(id(exception[1])) |
| 450 | chained_tb = self.structured_traceback_doctest(etype, evalue, (etb, chained_exc_ids), 0, context) |
| 451 | out_list = chained_tb + chained_exception_message + out_list |
| 452 | |
| 453 | return out_list |
| 454 | |
| 455 | def show_exception_only( |
| 456 | self, etype: BaseException | None, evalue: TracebackType | None |
no test coverage detected