Skip to content

Commit

Permalink
Set globals in pytests
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez authored Dec 16, 2024
1 parent ddba82f commit 678142d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,17 @@ def doctest_run(
out: Any = None,
clear_globs: bool = True,
) -> doctest.TestResults:
from sage.repl.rich_output import get_display_manager
from sage.repl.user_globals import set_globals

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)

# Ensure that injecting globals works as expected in doctests
set_globals(test.globs)
return old_run(self, test, compileflags, out, clear_globs)


Expand Down

0 comments on commit 678142d

Please sign in to comment.