Skip to content

sage.doctest: Make imports more specific; make global environment for tests customizable #29922

@mkoeppe

Description

@mkoeppe

We prepare the Sage doctesting module for running in environments where sage.all is not available (#29705).

  1. An explicit import in sage.doctest.parsing:
# We need to import from sage.all to avoid circular imports.
from sage.all import RealIntervalField
RIFtol = RealIntervalField(1044)
  1. We make the global environment for tests customizable in sage.doctest.forker: in init_sage:
    import sage.repl.ipython_kernel.all_jupyter

and again in DocTestTask._run:

            # Import Jupyter globals to doctest the Jupyter
            # implementation of widgets and interacts
            import sage.repl.ipython_kernel.all_jupyter as sage_all

... which is

"""
All imports for Jupyter
"""

from sage.all_cmdline import *

from .widgets_sagenb import (input_box, text_control, slider,
        range_slider, checkbox, selector, input_grid, color_selector)
from .interact import interact

This is exposed by the new sage-runtest option --environment.

For example, #29865 defines modules such as sage.all__sage_objects. We would invoke sage -t --environment=sage.all__sage_objects to test against this global environment.

  1. We ignore errors importing sage.interfaces.

Depends on #29940

CC: @tscrim @fchapoton @orlitzky @kliem @kiwifb

Component: refactoring

Author: Matthias Koeppe

Branch/Commit: 2a602df

Reviewer: Jonathan Kliem

Issue created by migration from https://trac.sagemath.org/ticket/29922

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions