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 -t: Distinguish .pxd from .pyx in doctest basenames #36238

Merged
merged 2 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def skipfile(filename, tested_optional_tags=False, *,
if log:
log(f"Skipping '{filename}' because it is created by the jupyter-sphinx extension for internal use and should not be tested")
return True
if if_installed and ext in ('.py', '.pyx', '.pxd'):
if if_installed:
module_name = get_basename(filename)
try:
if not importlib.util.find_spec(module_name): # tries to import the containing package
Expand Down
12 changes: 9 additions & 3 deletions src/sage/doctest/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ def get_basename(path):
sage: from sage.doctest.sources import get_basename
sage: from sage.env import SAGE_SRC
sage: import os
sage: get_basename(os.path.join(SAGE_SRC,'sage','doctest','sources.py'))
sage: get_basename(os.path.join(SAGE_SRC, 'sage', 'doctest', 'sources.py'))
'sage.doctest.sources'
sage: get_basename(os.path.join(SAGE_SRC, 'sage', 'structure', 'element.pxd'))
'sage.structure.element.pxd'
"""
if path is None:
return None
Expand All @@ -111,10 +113,14 @@ def get_basename(path):
# it goes.
while is_package_or_sage_namespace_package_dir(root):
root = os.path.dirname(root)
fully_qualified_path = os.path.splitext(path[len(root) + 1:])[0]
fully_qualified_path, ext = os.path.splitext(path[len(root) + 1:])
if os.path.split(path)[1] == '__init__.py':
fully_qualified_path = fully_qualified_path[:-9]
return fully_qualified_path.replace(os.path.sep, '.')
basename = fully_qualified_path.replace(os.path.sep, '.')
if ext in ['.pxd', '.pxi']:
# disambiguate from .pyx with the same basename
basename += ext
return basename


class DocTestSource():
Expand Down
Loading