summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-09-16 14:10:31 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-09-16 14:10:31 +0200
commitf840f233418bd03a3bb83c3c70f1f9e074702b13 (patch)
tree1b79d88e90b2973f3ab84916dfc0417b8089f95f
parenteba93e9d7b64aa9435b12b9fce0ddc1155cc8dc5 (diff)
downloadnumpy-f840f233418bd03a3bb83c3c70f1f9e074702b13.tar.gz
TST,DOC: Skip the `__class_getitem__` doctests for python 3.8
-rw-r--r--tools/refguide_check.py43
1 files changed, 30 insertions, 13 deletions
diff --git a/tools/refguide_check.py b/tools/refguide_check.py
index 9a6d1c9f8..15c07803d 100644
--- a/tools/refguide_check.py
+++ b/tools/refguide_check.py
@@ -93,18 +93,27 @@ OTHER_MODULE_DOCS = {
# these names are known to fail doctesting and we like to keep it that way
# e.g. sometimes pseudocode is acceptable etc
-DOCTEST_SKIPLIST = set([
+#
+# Optionally, a subset of methods can be skipped by setting dict-values
+# to a container of method-names
+DOCTEST_SKIPDICT = {
# cases where NumPy docstrings import things from SciPy:
- 'numpy.lib.vectorize',
- 'numpy.random.standard_gamma',
- 'numpy.random.gamma',
- 'numpy.random.vonmises',
- 'numpy.random.power',
- 'numpy.random.zipf',
+ 'numpy.lib.vectorize': None,
+ 'numpy.random.standard_gamma': None,
+ 'numpy.random.gamma': None,
+ 'numpy.random.vonmises': None,
+ 'numpy.random.power': None,
+ 'numpy.random.zipf': None,
# remote / local file IO with DataSource is problematic in doctest:
- 'numpy.lib.DataSource',
- 'numpy.lib.Repository',
-])
+ 'numpy.lib.DataSource': None,
+ 'numpy.lib.Repository': None,
+}
+if sys.version_info < (3, 9):
+ DOCTEST_SKIPDICT.update({
+ "numpy.core.ndarray": {"__class_getitem__"},
+ "numpy.core.dtype": {"__class_getitem__"},
+ "numpy.core.number": {"__class_getitem__"},
+ })
# Skip non-numpy RST files, historical release notes
# Any single-directory exact match will skip the directory and all subdirs.
@@ -870,8 +879,12 @@ def check_doctests(module, verbose, ns=None,
for name in get_all_dict(module)[0]:
full_name = module.__name__ + '.' + name
- if full_name in DOCTEST_SKIPLIST:
- continue
+ if full_name in DOCTEST_SKIPDICT:
+ skip_methods = DOCTEST_SKIPDICT[full_name]
+ if skip_methods is None:
+ continue
+ else:
+ skip_methods = None
try:
obj = getattr(module, name)
@@ -892,6 +905,10 @@ def check_doctests(module, verbose, ns=None,
traceback.format_exc()))
continue
+ if skip_methods is not None:
+ tests = [i for i in tests if
+ i.name.partition(".")[2] not in skip_methods]
+
success, output = _run_doctests(tests, full_name, verbose,
doctest_warnings)
@@ -972,7 +989,7 @@ def check_doctests_testfile(fname, verbose, ns=None,
results = []
_, short_name = os.path.split(fname)
- if short_name in DOCTEST_SKIPLIST:
+ if short_name in DOCTEST_SKIPDICT:
return results
full_name = fname