Skip to content

Commit fafaaf2

Browse files
author
Matthias Koeppe
committed
sage -t, sage -fixdoctests: Rename option --only-lib to --if-installed
1 parent b801474 commit fafaaf2

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/bin/sage-fixdoctests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ if not args.no_test:
320320
environment_args = f'--environment {args.environment} ' if args.environment != runtest_default_environment else ''
321321
long_args = f'--long ' if args.long else ''
322322
probe_args = f'--probe {shlex.quote(args.probe)} ' if args.probe else ''
323-
lib_args = f'--only-lib ' if args.venv else ''
323+
lib_args = f'--if-installed ' if args.venv else ''
324324
doc_file = tmp_filename()
325325
if args.venv or environment_args:
326326
input = os.path.join(os.path.relpath(SAGE_ROOT), 'src', 'sage', 'version.py')

src/bin/sage-runtests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if __name__ == "__main__":
6969
parser.add_argument("-i", "--initial", action="store_true", default=False, help="only show the first failure in each file")
7070
parser.add_argument("--exitfirst", action="store_true", default=False, help="end the test run immediately after the first failure or unexpected exception")
7171
parser.add_argument("--force_lib", "--force-lib", action="store_true", default=False, help="do not import anything from the tested file(s)")
72-
parser.add_argument("--only-lib", action="store_true", default=False, help="skip Python/Cython files that are not installed as modules")
72+
parser.add_argument("--if-installed", action="store_true", default=False, help="skip Python/Cython files that are not installed as modules")
7373
parser.add_argument("--abspath", action="store_true", default=False, help="print absolute paths rather than relative paths")
7474
parser.add_argument("--verbose", action="store_true", default=False, help="print debugging output during the test")
7575
parser.add_argument("-d", "--debug", action="store_true", default=False, help="drop into a python debugger when an unexpected error is raised")

src/doc/en/developer/doctesting.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,17 +1392,17 @@ tree (``src/sage/...``)::
13921392

13931393
Note that testing all doctests as they appear in the source tree does not make sense
13941394
because many of the source files may not be installed in the virtual environment.
1395-
Use the option ``--only-lib`` to skip the source files of all Python/Cython modules
1395+
Use the option ``--if-installed`` to skip the source files of all Python/Cython modules
13961396
that are not installed in the virtual environment::
13971397

13981398
[mkoeppe@sage sage]$ pkgs/sagemath-categories/.tox/sagepython-sagewheels-.../sage -t \
1399-
-p4 --environment sage.all__sagemath_categories --only-lib \
1399+
-p4 --environment sage.all__sagemath_categories --if-installed \
14001400
src/sage/schemes
14011401

14021402
This option can also be combined with ``--all``::
14031403

14041404
[mkoeppe@sage sage]$ pkgs/sagemath-categories/.tox/sagepython-sagewheels-.../sage -t \
1405-
-p4 --environment sage.all__sagemath_categories --only-lib \
1405+
-p4 --environment sage.all__sagemath_categories --if-installed \
14061406
--all
14071407

14081408

@@ -1645,7 +1645,7 @@ that uses the more specific options ``--venv`` and ``--environment``::
16451645
src/sage/geometry/schemes/generic/*.py
16461646

16471647
Either way, the options ``--keep-both``, ``--full-tracebacks``, and
1648-
``--only-lib`` are implied.
1648+
``--if-installed`` are implied.
16491649

16501650
In this mode of operation, when the doctester encounters a global name
16511651
that is unknown in its virtual environment (:class:`NameError`),

src/sage/doctest/control.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def __init__(self, **kwds):
123123
self.initial = False
124124
self.exitfirst = False
125125
self.force_lib = False
126-
self.only_lib = False
126+
self.if_installed = False
127127
self.abspath = True # sage-runtests default is False
128128
self.verbose = False
129129
self.debug = False
@@ -225,7 +225,7 @@ def skipdir(dirname):
225225
return False
226226

227227
def skipfile(filename, tested_optional_tags=False, *,
228-
only_lib=False, log=None):
228+
if_installed=False, log=None):
229229
"""
230230
Return ``True`` if and only if the file ``filename`` should not be doctested.
231231
@@ -236,7 +236,7 @@ def skipfile(filename, tested_optional_tags=False, *,
236236
- ``tested_optional_tags`` -- a list or tuple or set of optional tags to test,
237237
or ``False`` (no optional test) or ``True`` (all optional tests)
238238
239-
- ``only_lib`` -- (boolean, default ``False``) whether to skip Python/Cython files
239+
- ``if_installed`` -- (boolean, default ``False``) whether to skip Python/Cython files
240240
that are not installed as modules
241241
242242
- ``log`` -- function to call with log messages, or ``None``
@@ -285,7 +285,7 @@ def skipfile(filename, tested_optional_tags=False, *,
285285
if log:
286286
log(f"Skipping '{filename}' because it is created by the jupyter-sphinx extension for internal use and should not be tested")
287287
return True
288-
if only_lib and ext in ('.py', '.pyx', '.pxd'):
288+
if if_installed and ext in ('.py', '.pyx', '.pxd'):
289289
module_name = get_basename(filename)
290290
try:
291291
if not importlib.util.find_spec(module_name): # tries to import the containing package
@@ -949,7 +949,7 @@ def all_doc_sources():
949949
filename.endswith(".rst"))
950950
and not skipfile(opj(SAGE_ROOT, filename),
951951
True if self.options.optional else False,
952-
only_lib=self.options.only_lib)):
952+
if_installed=self.options.if_installed)):
953953
self.files.append(os.path.relpath(opj(SAGE_ROOT, filename)))
954954

955955
def expand_files_into_sources(self):
@@ -1011,11 +1011,11 @@ def expand():
10111011
for file in files:
10121012
if not skipfile(os.path.join(root, file),
10131013
True if self.options.optional else False,
1014-
only_lib=self.options.only_lib):
1014+
if_installed=self.options.if_installed):
10151015
yield os.path.join(root, file)
10161016
else:
10171017
if not skipfile(path, True if self.options.optional else False,
1018-
only_lib=self.options.only_lib, log=self.log): # log when directly specified filenames are skipped
1018+
if_installed=self.options.if_installed, log=self.log): # log when directly specified filenames are skipped
10191019
yield path
10201020
self.sources = [FileDocTestSource(path, self.options) for path in expand()]
10211021

0 commit comments

Comments
 (0)