(self)
| 343 | self.dtest.globs.clear() |
| 344 | |
| 345 | def runtest(self) -> None: |
| 346 | assert self.dtest is not None |
| 347 | assert self.runner is not None |
| 348 | _check_all_skipped(self.dtest) |
| 349 | self._disable_output_capturing_for_darwin() |
| 350 | failures: List[doctest.DocTestFailure] = [] |
| 351 | |
| 352 | # exec(compile(..., "single", ...), ...) puts result in builtins._ |
| 353 | had_underscore_value = hasattr(builtins, "_") |
| 354 | underscore_original_value = getattr(builtins, "_", None) |
| 355 | |
| 356 | # Save our current directory and switch out to the one where the |
| 357 | # test was originally created, in case another doctest did a |
| 358 | # directory change. We'll restore this in the finally clause. |
| 359 | curdir = os.getcwd() |
| 360 | os.chdir(self.fspath.dirname) |
| 361 | try: |
| 362 | # Type ignored because we change the type of `out` from what |
| 363 | # ipdoctest expects. |
| 364 | self.runner.run(self.dtest, out=failures, clear_globs=False) # type: ignore[arg-type] |
| 365 | finally: |
| 366 | os.chdir(curdir) |
| 367 | if had_underscore_value: |
| 368 | setattr(builtins, "_", underscore_original_value) |
| 369 | elif hasattr(builtins, "_"): |
| 370 | delattr(builtins, "_") |
| 371 | |
| 372 | if failures: |
| 373 | raise MultipleDoctestFailures(failures) |
| 374 | |
| 375 | def _disable_output_capturing_for_darwin(self) -> None: |
| 376 | """Disable output capturing. Otherwise, stdout is lost to ipdoctest (pytest#985).""" |
nothing calls this directly
no test coverage detected