A stripped down version of Verbose TB, simplified to not have too much information when running doctests
| 82 | |
| 83 | |
| 84 | class DocTB(TBTools): |
| 85 | """ |
| 86 | |
| 87 | A stripped down version of Verbose TB, simplified to not have too much information when |
| 88 | running doctests |
| 89 | |
| 90 | """ |
| 91 | |
| 92 | tb_highlight = "" |
| 93 | tb_highlight_style = "default" |
| 94 | tb_offset: int |
| 95 | long_header: bool |
| 96 | include_vars: bool |
| 97 | |
| 98 | _mode: str |
| 99 | |
| 100 | def __init__( |
| 101 | self, |
| 102 | # TODO: no default ? |
| 103 | theme_name: str = "linux", |
| 104 | call_pdb: bool = False, |
| 105 | ostream: Any = None, |
| 106 | tb_offset: int = 0, |
| 107 | long_header: bool = False, |
| 108 | include_vars: bool = True, |
| 109 | check_cache: Callable[[], None] | None = None, |
| 110 | debugger_cls: type | None = None, |
| 111 | ): |
| 112 | """Specify traceback offset, headers and color scheme. |
| 113 | |
| 114 | Define how many frames to drop from the tracebacks. Calling it with |
| 115 | tb_offset=1 allows use of this handler in interpreters which will have |
| 116 | their own code at the top of the traceback (VerboseTB will first |
| 117 | remove that frame before printing the traceback info).""" |
| 118 | assert isinstance(theme_name, str) |
| 119 | super().__init__( |
| 120 | theme_name=theme_name, |
| 121 | call_pdb=call_pdb, |
| 122 | ostream=ostream, |
| 123 | debugger_cls=debugger_cls, |
| 124 | ) |
| 125 | self.tb_offset = tb_offset |
| 126 | self.long_header = long_header |
| 127 | self.include_vars = include_vars |
| 128 | # By default we use linecache.checkcache, but the user can provide a |
| 129 | # different check_cache implementation. This was formerly used by the |
| 130 | # IPython kernel for interactive code, but is no longer necessary. |
| 131 | if check_cache is None: |
| 132 | check_cache = linecache.checkcache |
| 133 | self.check_cache = check_cache |
| 134 | |
| 135 | self.skip_hidden = True |
| 136 | |
| 137 | def format_record(self, frame_info: FrameInfo) -> str: |
| 138 | """Format a single stack frame""" |
| 139 | assert isinstance(frame_info, FrameInfo) |
| 140 | |
| 141 | if isinstance(frame_info._sd, stack_data.RepeatedFrames): |
no outgoing calls
no test coverage detected
searching dependent graphs…