Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mkoeppe opened this issue Jun 20, 2020 · 25 comments

Comments

@mkoeppe
Copy link
Member

mkoeppe commented Jun 20, 2020

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

@mkoeppe mkoeppe added this to the sage-9.2 milestone Jun 20, 2020
@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe changed the title sage.doctest: Make imports more specific sage.doctest: Make imports more specific; make global environment for tests customizable Jun 20, 2020
@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Member Author

mkoeppe commented Jun 22, 2020

comment:6

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.

@mkoeppe
Copy link
Member Author

mkoeppe commented Jun 22, 2020

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

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

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

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

Commit: 7d86833

@mkoeppe
Copy link
Member Author

mkoeppe commented Jun 22, 2020

comment:10

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

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

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

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

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

Changed commit from 7d86833 to b3ab1c1

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

Changed commit from b3ab1c1 to 66572cd

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

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

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

@mkoeppe
Copy link
Member Author

mkoeppe commented Jun 22, 2020

Dependencies: #29940

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

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

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

Changed commit from 66572cd to 67db00f

@mkoeppe
Copy link
Member Author

mkoeppe commented Jun 22, 2020

Author: Matthias Koeppe

@mkoeppe

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

Changed commit from 67db00f to 2a602df

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2020

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

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 2, 2020

comment:19

Ready for review

@kliem
Copy link
Contributor

kliem commented Jul 17, 2020

Reviewer: Jonathan Kliem

@kliem
Copy link
Contributor

kliem commented Jul 17, 2020

comment:21

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

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 17, 2020

comment:22

Thank you.

@vbraun
Copy link
Member

vbraun commented Jul 25, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants