Skip to content

Commit

Permalink
Fix exception printing also in isolated mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez authored Dec 13, 2024
1 parent 6f9861f commit a3845f6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,6 @@ def format_exception_only(etype: type, value: BaseException) -> list[str]:
return formatted_exception


traceback.format_exception_only = format_exception_only

# Display warnings in doctests
warnings.showwarning = showwarning_with_traceback

from sage.repl.rich_output import get_display_manager

# Initialize Sage-specific doctest stuff
init_sage()

Expand All @@ -269,6 +262,13 @@ def doctest_run(
out: Any = None,
clear_globs: bool = True,
) -> doctest.TestResults:
traceback.format_exception_only = format_exception_only

# Display warnings in doctests
warnings.showwarning = showwarning_with_traceback

from sage.repl.rich_output import get_display_manager

setattr(sys, "__displayhook__", get_display_manager().displayhook)
return old_run(self, test, compileflags, out, clear_globs)

Expand Down

0 comments on commit a3845f6

Please sign in to comment.