Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
sage.doctest.control, sage.features.sagemath: Provide/use optional tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Oct 3, 2021
1 parent 2938e13 commit 747b458
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
except ImportError:
pass

from sage.features.sagemath import sage_optional_tags
auto_optional_tags |= sage_optional_tags()

class DocTestDefaults(SageObject):
"""
This class is used for doctesting the Sage doctest module.
Expand Down
28 changes: 28 additions & 0 deletions src/sage/features/sagemath.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
class sage__combinat(PythonModule):

def __init__(self):
# sage.combinat will be a namespace package.
# Testing whether sage.combinat itself can be imported is meaningless.
# Hence, we test a Python module within the package.
PythonModule.__init__('sage.combinat.combinations')


Expand All @@ -26,3 +29,28 @@ class sage__symbolic(PythonModule):

def __init__(self):
PythonModule.__init__('sage.symbolic.expression', spkg="sagemath_symbolics")


def sage_optional_tags():
"""
Return tags for conditionalizing doctests.
These tags are named after Python packages/modules (e.g., :mod:`~sage.symbolic`),
not distribution packages (``sagemath-symbolics``).
This is motivated by a separation of concerns: The author of a module that depends
on some functionality provided by a Python module usually already knows the
name of the Python module, so we do not want to force the author to also
know about the distribution package that provides the Python module.
Instead, we associate distribution packages to Python modules in
:mod:`sage.features.sagemath` via the ``spkg`` parameter of :class:`PythonModule``.
"""
if sage__combinat().is_functional():
yield 'sage.combinat'
if sage__graphs().is_functional():
yield 'sage.graphs'
if sage__rings__real_double().is_functional():
yield 'sage.rings.real_double'
if sage__symbolic().is_functional():
yield 'sage.symbolic'

0 comments on commit 747b458

Please sign in to comment.