Opened 2 years ago

Closed 22 months ago

#29922 closed enhancement (fixed)

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

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-9.2
Component: refactoring Keywords:
Cc: tscrim, chapoton, mjo, gh-kliem, fbissey Merged in:
Authors: Matthias Koeppe Reviewers: Jonathan Kliem
Report Upstream: N/A Work issues:
Branch: 2a602df (Commits, GitHub, GitLab) Commit: 2a602df11ae0e6d3b8d8d964636c75063b51df43
Dependencies: #29940 Stopgaps:

Status badges

Description (last modified by 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.

Change History (23)

comment:1 Changed 2 years ago by mkoeppe

  • Description modified (diff)

comment:2 Changed 2 years ago by mkoeppe

  • Description modified (diff)
  • Summary changed from sage.doctest: Make imports more specific to sage.doctest: Make imports more specific; make global environment for tests customizable

comment:3 Changed 2 years ago by mkoeppe

  • Description modified (diff)

comment:4 Changed 2 years ago by mkoeppe

  • Cc mjo added

comment:5 Changed 2 years ago by mkoeppe

  • Description modified (diff)

comment:6 Changed 2 years ago by mkoeppe

Probably we will need to disable the real tolerance feature when we want to test the lowest layers such as sage-objects to avoid having to pull in the whole numeric tower.

comment:7 Changed 2 years ago by mkoeppe

  • Branch set to u/mkoeppe/sage_doctest__make_imports_more_specific__make_global_environment_for_tests_customizable

comment:8 Changed 2 years ago by git

  • Commit set to 7d86833b96726e0a631aaea217c85be593f96bf8

Branch pushed to git repo; I updated commit sha1. New commits:

7d86833sage.doctest.forker: Do not fail if sage.interfaces.quit cannot be imported

comment:9 Changed 2 years ago by mkoeppe

  • Cc gh-kliem added

comment:10 Changed 2 years ago by mkoeppe

Cc'ing you because this ticket is touching the same files that will need to be modified if you want to implement the option for #29935

comment:11 Changed 2 years ago by git

  • Commit changed from 7d86833b96726e0a631aaea217c85be593f96bf8 to b3ab1c1efcf1870340afba7a965cf60044addac2

Branch pushed to git repo; I updated commit sha1. New commits:

b3ab1c1src/bin/sage-runtests: Add --environment option

comment:12 Changed 2 years ago by git

  • Commit changed from b3ab1c1efcf1870340afba7a965cf60044addac2 to 66572cdecde05cd7fafe3f229169f96e2b697956

Branch pushed to git repo; I updated commit sha1. New commits:

9757019sage.doctest.forker.DocTestTask._run: Remove special support for sagenb
66572cdWIP

comment:13 Changed 2 years ago by mkoeppe

  • Dependencies set to #29940

comment:14 Changed 2 years ago by git

  • Commit changed from 66572cdecde05cd7fafe3f229169f96e2b697956 to 67db00f1d9432739a6849aded2428c835795ae6b

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

6bec225sage.doctest.forker.DocTestTask._run: Remove special support for sagenb
ad00b40sage.doctest, src/bin/sage-runtests: Remove handling of sagenb
faef943Merge branch 't/29940/sage_doctest__remove_handling_of_sagenb' into t/29922/sage_doctest__make_imports_more_specific__make_global_environment_for_tests_customizable
67db00fsrc/bin/sage-runtests, sage.doctest: Handle option --environment

comment:15 Changed 2 years ago by mkoeppe

  • Authors set to Matthias Koeppe
  • Description modified (diff)
  • Status changed from new to needs_review

comment:16 Changed 2 years ago by mkoeppe

  • Status changed from needs_review to needs_work

comment:17 Changed 2 years ago by git

  • Commit changed from 67db00f1d9432739a6849aded2428c835795ae6b to 2a602df11ae0e6d3b8d8d964636c75063b51df43

Branch pushed to git repo; I updated commit sha1. New commits:

9bf6f88sage.doctest.control: Remove unused import
89988cfsage.doctest.forker.init_sage: Actually handle the optional arg
2664865sage.misc.package: Do not fail if SAGE_PKGS, SAGE_SPKG_INST do not exist
2a602dfsage.repl.display.fancy_repr: Do not fail if sage.matrix.matrix1 canno be imported

comment:18 Changed 2 years ago by mkoeppe

  • Status changed from needs_work to needs_review

comment:19 Changed 23 months ago by mkoeppe

Ready for review

comment:20 Changed 22 months ago by mkoeppe

  • Cc fbissey added

comment:21 Changed 22 months ago by gh-kliem

  • Reviewers set to Jonathan Kliem
  • Status changed from needs_review to positive_review

This looks reasonable, it does not break the doctesting framework and the added doctests pass.

comment:22 Changed 22 months ago by mkoeppe

Thank you.

comment:23 Changed 22 months ago by vbraun

  • Branch changed from u/mkoeppe/sage_doctest__make_imports_more_specific__make_global_environment_for_tests_customizable to 2a602df11ae0e6d3b8d8d964636c75063b51df43
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.