diff options
author | mattip <matti.picus@gmail.com> | 2019-10-17 20:54:17 +0300 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2019-10-17 20:54:17 +0300 |
commit | 5af0ca9c3eb4d49423bc34658164c742d92dd280 (patch) | |
tree | 2e26c5616ea027b22edbf51b58f57a66f66f17e0 /tools/refguide_check.py | |
parent | 0b474e3ee75d1086379e5f3e5cfc75594bbe56fc (diff) | |
download | numpy-5af0ca9c3eb4d49423bc34658164c742d92dd280.tar.gz |
TST: changes from review
Diffstat (limited to 'tools/refguide_check.py')
-rw-r--r-- | tools/refguide_check.py | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/tools/refguide_check.py b/tools/refguide_check.py index 874a6dce0..66d173051 100644 --- a/tools/refguide_check.py +++ b/tools/refguide_check.py @@ -852,14 +852,9 @@ def check_doctests_testfile(fname, verbose, ns=None, return results -def check_rst(base_path, results, args, dots): +def iter_included_files(base_path, args, suffixes=('.py', '.rst')): if os.path.exists(base_path) and os.path.isfile(base_path): - tut_results = check_doctests_testfile(base_path, - (args.verbose >= 2), dots=dots, - doctest_warnings=args.doctest_warnings) - def scratch(): pass # stub out a "module", see below - scratch.__name__ = base_path - results.append((scratch, tut_results)) + yield base_path for dir_name, subdirs, files in os.walk(base_path, topdown=True): if dir_name in RST_SKIPLIST: if args.verbose > 0: @@ -870,28 +865,27 @@ def check_rst(base_path, results, args, dots): if args.verbose > 0: sys.stderr.write('skipping %s and subdirs' % p) subdirs.remove(p) - test_files = [] for f in files: - if (os.path.splitext(f)[1] in ('.py', '.rst') and + if (os.path.splitext(f)[1] in suffixes and f not in RST_SKIPLIST): - test_files.append(f) - if len(test_files) > 1: - for fname in test_files: - filename = os.path.relpath(os.path.join(dir_name, fname)) - if dots: - sys.stderr.write(filename + ' ') - sys.stderr.flush() - - tut_results = check_doctests_testfile(filename, - (args.verbose >= 2), dots=dots, - doctest_warnings=args.doctest_warnings) - - def scratch(): pass # stub out a "module", see below - scratch.__name__ = filename - results.append((scratch, tut_results)) - if dots: - sys.stderr.write('\n') - sys.stderr.flush() + yield os.path.join(dir_name, f) + +def check_rst(base_path, results, args, dots): + for filename in iter_included_files(base_path, args): + if dots: + sys.stderr.write(filename + ' ') + sys.stderr.flush() + + tut_results = check_doctests_testfile(filename, + (args.verbose >= 2), dots=dots, + doctest_warnings=args.doctest_warnings) + + def scratch(): pass # stub out a "module", see below + scratch.__name__ = filename + results.append((scratch, tut_results)) + if dots: + sys.stderr.write('\n') + sys.stderr.flush() def init_matplotlib(): global HAVE_MATPLOTLIB |