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:  sage9.2 
Component:  refactoring  Keywords:  
Cc:  tscrim, chapoton, mjo, ghkliem, 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: 
Description (last modified by )
We prepare the Sage doctesting module for running in environments where sage.all
is not available (#29705).
 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)
 We make the global environment for tests customizable in
sage.doctest.forker
: ininit_sage
:import sage.repl.ipython_kernel.all_jupyter
and again inDocTestTask._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
sageruntest
optionenvironment
.
For example, #29865 defines modules such as
sage.all__sage_objects
. We would invokesage t environment=sage.all__sage_objects
to test against this global environment.
 We ignore errors importing
sage.interfaces
.
Change History (23)
comment:1 Changed 2 years ago by
 Description modified (diff)
comment:2 Changed 2 years ago by
 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
 Description modified (diff)
comment:4 Changed 2 years ago by
 Cc mjo added
comment:5 Changed 2 years ago by
 Description modified (diff)
comment:6 Changed 2 years ago by
comment:7 Changed 2 years ago by
 Branch set to u/mkoeppe/sage_doctest__make_imports_more_specific__make_global_environment_for_tests_customizable
comment:8 Changed 2 years ago by
 Commit set to 7d86833b96726e0a631aaea217c85be593f96bf8
Branch pushed to git repo; I updated commit sha1. New commits:
7d86833  sage.doctest.forker: Do not fail if sage.interfaces.quit cannot be imported

comment:9 Changed 2 years ago by
 Cc ghkliem added
comment:10 Changed 2 years ago by
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
 Commit changed from 7d86833b96726e0a631aaea217c85be593f96bf8 to b3ab1c1efcf1870340afba7a965cf60044addac2
Branch pushed to git repo; I updated commit sha1. New commits:
b3ab1c1  src/bin/sageruntests: Add environment option

comment:12 Changed 2 years ago by
 Commit changed from b3ab1c1efcf1870340afba7a965cf60044addac2 to 66572cdecde05cd7fafe3f229169f96e2b697956
comment:13 Changed 2 years ago by
 Dependencies set to #29940
comment:14 Changed 2 years ago by
 Commit changed from 66572cdecde05cd7fafe3f229169f96e2b697956 to 67db00f1d9432739a6849aded2428c835795ae6b
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
6bec225  sage.doctest.forker.DocTestTask._run: Remove special support for sagenb

ad00b40  sage.doctest, src/bin/sageruntests: Remove handling of sagenb

faef943  Merge branch 't/29940/sage_doctest__remove_handling_of_sagenb' into t/29922/sage_doctest__make_imports_more_specific__make_global_environment_for_tests_customizable

67db00f  src/bin/sageruntests, sage.doctest: Handle option environment

comment:15 Changed 2 years ago by
 Description modified (diff)
 Status changed from new to needs_review
comment:16 Changed 2 years ago by
 Status changed from needs_review to needs_work
comment:17 Changed 2 years ago by
 Commit changed from 67db00f1d9432739a6849aded2428c835795ae6b to 2a602df11ae0e6d3b8d8d964636c75063b51df43
Branch pushed to git repo; I updated commit sha1. New commits:
9bf6f88  sage.doctest.control: Remove unused import

89988cf  sage.doctest.forker.init_sage: Actually handle the optional arg

2664865  sage.misc.package: Do not fail if SAGE_PKGS, SAGE_SPKG_INST do not exist

2a602df  sage.repl.display.fancy_repr: Do not fail if sage.matrix.matrix1 canno be imported

comment:18 Changed 2 years ago by
 Status changed from needs_work to needs_review
comment:19 Changed 23 months ago by
Ready for review
comment:20 Changed 22 months ago by
 Cc fbissey added
comment:21 Changed 22 months ago by
 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
Thank you.
comment:23 Changed 22 months ago by
 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
Probably we will need to disable the real tolerance feature when we want to test the lowest layers such as
sageobjects
to avoid having to pull in the whole numeric tower.