()
| 202 | |
| 203 | |
| 204 | def _init_runner_class() -> Type["IPDocTestRunner"]: |
| 205 | import doctest |
| 206 | from .ipdoctest import IPDocTestRunner |
| 207 | |
| 208 | class PytestDoctestRunner(IPDocTestRunner): |
| 209 | """Runner to collect failures. |
| 210 | |
| 211 | Note that the out variable in this case is a list instead of a |
| 212 | stdout-like object. |
| 213 | """ |
| 214 | |
| 215 | def __init__( |
| 216 | self, |
| 217 | checker: Optional["IPDoctestOutputChecker"] = None, |
| 218 | verbose: Optional[bool] = None, |
| 219 | optionflags: int = 0, |
| 220 | continue_on_failure: bool = True, |
| 221 | ) -> None: |
| 222 | super().__init__(checker=checker, verbose=verbose, optionflags=optionflags) |
| 223 | self.continue_on_failure = continue_on_failure |
| 224 | |
| 225 | def report_failure( |
| 226 | self, |
| 227 | out, |
| 228 | test: "doctest.DocTest", |
| 229 | example: "doctest.Example", |
| 230 | got: str, |
| 231 | ) -> None: |
| 232 | failure = doctest.DocTestFailure(test, example, got) |
| 233 | if self.continue_on_failure: |
| 234 | out.append(failure) |
| 235 | else: |
| 236 | raise failure |
| 237 | |
| 238 | def report_unexpected_exception( |
| 239 | self, |
| 240 | out, |
| 241 | test: "doctest.DocTest", |
| 242 | example: "doctest.Example", |
| 243 | exc_info: Tuple[Type[BaseException], BaseException, types.TracebackType], |
| 244 | ) -> None: |
| 245 | if isinstance(exc_info[1], OutcomeException): |
| 246 | raise exc_info[1] |
| 247 | if isinstance(exc_info[1], bdb.BdbQuit): |
| 248 | outcomes.exit("Quitting debugger") |
| 249 | failure = doctest.UnexpectedException(test, example, exc_info) |
| 250 | if self.continue_on_failure: |
| 251 | out.append(failure) |
| 252 | else: |
| 253 | raise failure |
| 254 | |
| 255 | return PytestDoctestRunner |
| 256 | |
| 257 | |
| 258 | def _get_runner( |
no outgoing calls
no test coverage detected
searching dependent graphs…