From e929807cd64035d96d4562fc9583a045f7b53764 Mon Sep 17 00:00:00 2001 From: embrown Date: Wed, 11 Jan 2017 11:32:29 -0800 Subject: [PATCH 1/3] Adds doctesting to the VCS test suite. Currently only queries test is implemented. Once https://github.com/UV-CDAT/vcs/pull/114 is merged, this test will pass. Tests for other modules/classes will be very similar. Already did some setup for running with vcs.Canvas. A few of the steps in this script aren't necessary for queries, but will be needed for others (the cleanup step is mainly for Canvas and manageElements). If docstring contains '.. pragma: skip-doctest', the doctest for that docstring will not be run. If docstring is empty and not private, and has not been skipped, it will be printed in a "NO DOCUMENTATION" list after the tests so we can view it on cdash, but it will not cause a failure. --- testing/vcs/test_vcs_docstrings_queries.py | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 testing/vcs/test_vcs_docstrings_queries.py diff --git a/testing/vcs/test_vcs_docstrings_queries.py b/testing/vcs/test_vcs_docstrings_queries.py new file mode 100644 index 0000000000..b67f488248 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_queries.py @@ -0,0 +1,65 @@ +from vcs import queries +import vcs.utils +import glob +import os +import doctest + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.json", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(queries) # list of objects with non-empty docstrings +failed = False +doctest_failed = [] +no_doctest = [] +no_docstring = [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Reporting section +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All tests passed for vcs.queries") + From dd07237d5676aecc6992c77fe7757d516e8508b9 Mon Sep 17 00:00:00 2001 From: embrown Date: Wed, 11 Jan 2017 11:51:05 -0800 Subject: [PATCH 2/3] Added test to CMakeLists.txt --- testing/vcs/CMakeLists.txt | 4 ++++ testing/vcs/test_vcs_docstrings_queries.py | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt index 6065f75135..03d6c52fbf 100644 --- a/testing/vcs/CMakeLists.txt +++ b/testing/vcs/CMakeLists.txt @@ -1197,6 +1197,10 @@ cdat_add_test(test_vcs_textextents ${BASELINE_DIR}/test_textextents.png ) +cdat_add_test(test_vcs_docstrings_queries + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_queries.py +) add_subdirectory(vtk_ui) diff --git a/testing/vcs/test_vcs_docstrings_queries.py b/testing/vcs/test_vcs_docstrings_queries.py index b67f488248..21eed7e23e 100644 --- a/testing/vcs/test_vcs_docstrings_queries.py +++ b/testing/vcs/test_vcs_docstrings_queries.py @@ -23,9 +23,7 @@ def cleanup(): runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) objs = f.find(queries) # list of objects with non-empty docstrings failed = False -doctest_failed = [] -no_doctest = [] -no_docstring = [] +doctest_failed, no_doctest, no_docstring = [], [], [] if not os.path.isdir(vcs.sample_data): vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data for obj in objs: @@ -46,7 +44,7 @@ def cleanup(): no_doctest.append(obj.name) cleanup() # testing done -# Reporting section +# Report summary for cdash if len(doctest_failed): print "FAILING DOCTESTS:" for name in doctest_failed: From dc75ba78a7b5b2c32e0cd06444f1cbd25f7b5b08 Mon Sep 17 00:00:00 2001 From: embrown Date: Thu, 12 Jan 2017 12:28:19 -0800 Subject: [PATCH 3/3] Added testing for: * Canvas.py * boxfill.py * colormap.py * displayplot.py * fillarea.py * isofill.py * isoline.py * line.py * manageElements.py * marker.py * meshfill.py * projection.py * taylordiagram.py * template.py * textcombined.py * textorientation.py * texttable.py --- testing/vcs/CMakeLists.txt | 84 +++++++++++++++++++ testing/vcs/test_vcs_docstrings_Canvas.py | 74 ++++++++++++++++ testing/vcs/test_vcs_docstrings_boxfill.py | 66 +++++++++++++++ testing/vcs/test_vcs_docstrings_colormap.py | 66 +++++++++++++++ .../vcs/test_vcs_docstrings_displayplot.py | 66 +++++++++++++++ testing/vcs/test_vcs_docstrings_fillarea.py | 66 +++++++++++++++ testing/vcs/test_vcs_docstrings_isofill.py | 66 +++++++++++++++ testing/vcs/test_vcs_docstrings_isoline.py | 66 +++++++++++++++ testing/vcs/test_vcs_docstrings_line.py | 66 +++++++++++++++ .../vcs/test_vcs_docstrings_manageElements.py | 74 ++++++++++++++++ testing/vcs/test_vcs_docstrings_marker.py | 74 ++++++++++++++++ testing/vcs/test_vcs_docstrings_meshfill.py | 66 +++++++++++++++ testing/vcs/test_vcs_docstrings_projection.py | 74 ++++++++++++++++ testing/vcs/test_vcs_docstrings_queries.py | 7 +- .../vcs/test_vcs_docstrings_taylordiagram.py | 74 ++++++++++++++++ testing/vcs/test_vcs_docstrings_template.py | 74 ++++++++++++++++ .../vcs/test_vcs_docstrings_textcombined.py | 74 ++++++++++++++++ .../test_vcs_docstrings_textorientation.py | 74 ++++++++++++++++ testing/vcs/test_vcs_docstrings_texttable.py | 74 ++++++++++++++++ 19 files changed, 1283 insertions(+), 2 deletions(-) create mode 100644 testing/vcs/test_vcs_docstrings_Canvas.py create mode 100644 testing/vcs/test_vcs_docstrings_boxfill.py create mode 100644 testing/vcs/test_vcs_docstrings_colormap.py create mode 100644 testing/vcs/test_vcs_docstrings_displayplot.py create mode 100644 testing/vcs/test_vcs_docstrings_fillarea.py create mode 100644 testing/vcs/test_vcs_docstrings_isofill.py create mode 100644 testing/vcs/test_vcs_docstrings_isoline.py create mode 100644 testing/vcs/test_vcs_docstrings_line.py create mode 100644 testing/vcs/test_vcs_docstrings_manageElements.py create mode 100644 testing/vcs/test_vcs_docstrings_marker.py create mode 100644 testing/vcs/test_vcs_docstrings_meshfill.py create mode 100644 testing/vcs/test_vcs_docstrings_projection.py create mode 100644 testing/vcs/test_vcs_docstrings_taylordiagram.py create mode 100644 testing/vcs/test_vcs_docstrings_template.py create mode 100644 testing/vcs/test_vcs_docstrings_textcombined.py create mode 100644 testing/vcs/test_vcs_docstrings_textorientation.py create mode 100644 testing/vcs/test_vcs_docstrings_texttable.py diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt index 03d6c52fbf..cefa01e92d 100644 --- a/testing/vcs/CMakeLists.txt +++ b/testing/vcs/CMakeLists.txt @@ -1197,11 +1197,95 @@ cdat_add_test(test_vcs_textextents ${BASELINE_DIR}/test_textextents.png ) +cdat_add_test(test_vcs_docstrings_boxfill + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_boxfill.py +) + +cdat_add_test(test_vcs_docstrings_Canvas + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_Canvas.py +) + +cdat_add_test(test_vcs_docstrings_colormap + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_colormap.py +) + +cdat_add_test(test_vcs_docstrings_displayplot + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_Canvas.py +) + +cdat_add_test(test_vcs_docstrings_fillarea + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_fillarea.py +) + +cdat_add_test(test_vcs_docstrings_isofill + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_isofill.py +) + +cdat_add_test(test_vcs_docstrings_isoline + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_isoline.py +) + +cdat_add_test(test_vcs_docstrings_line + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_line.py +) + +cdat_add_test(test_vcs_docstrings_manageElements + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_manageElements.py +) + +cdat_add_test(test_vcs_docstrings_marker + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_marker.py +) + +cdat_add_test(test_vcs_docstrings_meshfill + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_meshfill.py +) + +cdat_add_test(test_vcs_docstrings_projection + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_projection.py +) + cdat_add_test(test_vcs_docstrings_queries "${PYTHON_EXECUTABLE}" ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_queries.py ) +cdat_add_test(test_vcs_docstrings_taylordiagram + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_taylordiagram.py +) + +cdat_add_test(test_vcs_docstrings_template + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_template.py +) + +cdat_add_test(test_vcs_docstrings_textcombined + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_textcombined.py +) + +cdat_add_test(test_vcs_docstrings_textorientation + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_textorientation.py +) + +cdat_add_test(test_vcs_docstrings_texttable + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_docstrings_texttable.py +) add_subdirectory(vtk_ui) add_subdirectory(editors) diff --git a/testing/vcs/test_vcs_docstrings_Canvas.py b/testing/vcs/test_vcs_docstrings_Canvas.py new file mode 100644 index 0000000000..5f1727bf11 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_Canvas.py @@ -0,0 +1,74 @@ +from vcs.Canvas import Canvas +import vcs.utils +import glob +import os +import doctest + + +# for testing. remove when done +def find_obj(olist, name): + for obj in olist: + if obj.name == name: + return obj + print ("No object named " + name) + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Canvas) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + elif obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.Canvas") + diff --git a/testing/vcs/test_vcs_docstrings_boxfill.py b/testing/vcs/test_vcs_docstrings_boxfill.py new file mode 100644 index 0000000000..8e8f99e61d --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_boxfill.py @@ -0,0 +1,66 @@ +from vcs.boxfill import Gfb +import vcs.utils +import glob +import os +import doctest + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg", "new_box.json"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Gfb) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + if obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.boxfill") + diff --git a/testing/vcs/test_vcs_docstrings_colormap.py b/testing/vcs/test_vcs_docstrings_colormap.py new file mode 100644 index 0000000000..c75c02e11e --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_colormap.py @@ -0,0 +1,66 @@ +from vcs.colormap import Cp +import vcs.utils +import glob +import os +import doctest + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Cp) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + if obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.colormap") + diff --git a/testing/vcs/test_vcs_docstrings_displayplot.py b/testing/vcs/test_vcs_docstrings_displayplot.py new file mode 100644 index 0000000000..08d3812ac2 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_displayplot.py @@ -0,0 +1,66 @@ +from vcs.displayplot import Dp +import vcs.utils +import glob +import os +import doctest + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Dp) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + if obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.displayplot") + diff --git a/testing/vcs/test_vcs_docstrings_fillarea.py b/testing/vcs/test_vcs_docstrings_fillarea.py new file mode 100644 index 0000000000..5888d12f21 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_fillarea.py @@ -0,0 +1,66 @@ +from vcs.fillarea import Tf +import vcs.utils +import glob +import os +import doctest + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Tf) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + if obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.fillarea") + diff --git a/testing/vcs/test_vcs_docstrings_isofill.py b/testing/vcs/test_vcs_docstrings_isofill.py new file mode 100644 index 0000000000..5e0b70cf57 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_isofill.py @@ -0,0 +1,66 @@ +from vcs.isofill import Gfi +import vcs.utils +import glob +import os +import doctest + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Gfi) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + if obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.isofill") + diff --git a/testing/vcs/test_vcs_docstrings_isoline.py b/testing/vcs/test_vcs_docstrings_isoline.py new file mode 100644 index 0000000000..be17084512 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_isoline.py @@ -0,0 +1,66 @@ +from vcs.isoline import Gi +import vcs.utils +import glob +import os +import doctest + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Gi) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + if obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.isoline") + diff --git a/testing/vcs/test_vcs_docstrings_line.py b/testing/vcs/test_vcs_docstrings_line.py new file mode 100644 index 0000000000..e9338933f6 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_line.py @@ -0,0 +1,66 @@ +from vcs.line import Tl +import vcs.utils +import glob +import os +import doctest + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Tl) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + if obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.line") + diff --git a/testing/vcs/test_vcs_docstrings_manageElements.py b/testing/vcs/test_vcs_docstrings_manageElements.py new file mode 100644 index 0000000000..45ca59de47 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_manageElements.py @@ -0,0 +1,74 @@ +from vcs import manageElements +import vcs.utils +import glob +import os +import doctest + + +# for testing. remove when done +def find_obj(olist, name): + for obj in olist: + if obj.name == name: + return obj + print ("No object named " + name) + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(manageElements) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + elif obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.manageElements") + diff --git a/testing/vcs/test_vcs_docstrings_marker.py b/testing/vcs/test_vcs_docstrings_marker.py new file mode 100644 index 0000000000..1fae4dd652 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_marker.py @@ -0,0 +1,74 @@ +from vcs.marker import Tm +import vcs.utils +import glob +import os +import doctest + + +# for testing. remove when done +def find_obj(olist, name): + for obj in olist: + if obj.name == name: + return obj + print ("No object named " + name) + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Tm) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + elif obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.marker") + diff --git a/testing/vcs/test_vcs_docstrings_meshfill.py b/testing/vcs/test_vcs_docstrings_meshfill.py new file mode 100644 index 0000000000..fe8a371275 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_meshfill.py @@ -0,0 +1,66 @@ +from vcs.meshfill import Gfm +import vcs.utils +import glob +import os +import doctest + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Gfm) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + if obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.meshfill") + diff --git a/testing/vcs/test_vcs_docstrings_projection.py b/testing/vcs/test_vcs_docstrings_projection.py new file mode 100644 index 0000000000..02eb1e4351 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_projection.py @@ -0,0 +1,74 @@ +from vcs.projection import Proj +import vcs.utils +import glob +import os +import doctest + + +# for testing. remove when done +def find_obj(olist, name): + for obj in olist: + if obj.name == name: + return obj + print ("No object named " + name) + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Proj) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + elif obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.projection") + diff --git a/testing/vcs/test_vcs_docstrings_queries.py b/testing/vcs/test_vcs_docstrings_queries.py index 21eed7e23e..6f8e4e1edc 100644 --- a/testing/vcs/test_vcs_docstrings_queries.py +++ b/testing/vcs/test_vcs_docstrings_queries.py @@ -10,7 +10,7 @@ def cleanup(): patterns list. """ gb = glob.glob - patterns = ["example.*", "*.json", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] for pattern in patterns: fnames = gb(pattern) for name in fnames: @@ -29,8 +29,11 @@ def cleanup(): for obj in objs: if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: continue # this is private or has been explicitly ignored; skip it. + if obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. if obj.docstring is '': no_docstring.append(obj.name) # store for empty docstring warning + continue examples = obj.examples if len(examples) > 0: # There are examples. Do they run? @@ -59,5 +62,5 @@ def cleanup(): print "\t" + name assert failed is False -print ("All tests passed for vcs.queries") +print ("All doctests passed for vcs.queries") diff --git a/testing/vcs/test_vcs_docstrings_taylordiagram.py b/testing/vcs/test_vcs_docstrings_taylordiagram.py new file mode 100644 index 0000000000..ef6c1efcea --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_taylordiagram.py @@ -0,0 +1,74 @@ +from vcs.taylor import Gtd +import vcs.utils +import glob +import os +import doctest + + +# for testing. remove when done +def find_obj(olist, name): + for obj in olist: + if obj.name == name: + return obj + print ("No object named " + name) + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Gtd) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + elif obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.taylor") + diff --git a/testing/vcs/test_vcs_docstrings_template.py b/testing/vcs/test_vcs_docstrings_template.py new file mode 100644 index 0000000000..a965711e91 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_template.py @@ -0,0 +1,74 @@ +from vcs.template import P +import vcs.utils +import glob +import os +import doctest + + +# for testing. remove when done +def find_obj(olist, name): + for obj in olist: + if obj.name == name: + return obj + print ("No object named " + name) + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(P) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + elif obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.template") + diff --git a/testing/vcs/test_vcs_docstrings_textcombined.py b/testing/vcs/test_vcs_docstrings_textcombined.py new file mode 100644 index 0000000000..f3560842bc --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_textcombined.py @@ -0,0 +1,74 @@ +from vcs.textcombined import Tc +import vcs.utils +import glob +import os +import doctest + + +# for testing. remove when done +def find_obj(olist, name): + for obj in olist: + if obj.name == name: + return obj + print ("No object named " + name) + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Tc) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + elif obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.textcombined") + diff --git a/testing/vcs/test_vcs_docstrings_textorientation.py b/testing/vcs/test_vcs_docstrings_textorientation.py new file mode 100644 index 0000000000..a183742339 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_textorientation.py @@ -0,0 +1,74 @@ +from vcs.textorientation import To +import vcs.utils +import glob +import os +import doctest + + +# for testing. remove when done +def find_obj(olist, name): + for obj in olist: + if obj.name == name: + return obj + print ("No object named " + name) + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(To) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + elif obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.textorientation") + diff --git a/testing/vcs/test_vcs_docstrings_texttable.py b/testing/vcs/test_vcs_docstrings_texttable.py new file mode 100644 index 0000000000..6bb5b03760 --- /dev/null +++ b/testing/vcs/test_vcs_docstrings_texttable.py @@ -0,0 +1,74 @@ +from vcs.texttable import Tt +import vcs.utils +import glob +import os +import doctest + + +# for testing. remove when done +def find_obj(olist, name): + for obj in olist: + if obj.name == name: + return obj + print ("No object named " + name) + + +def cleanup(): + """Cleanup for the doctests. If some files aren't being deleted after testing, add their glob signature to the + patterns list. + """ + gb = glob.glob + patterns = ["example.*", "*.svg", "ex_*", "my*", "filename.*", "*.png", "deft_box.py", "*.mpeg"] + for pattern in patterns: + fnames = gb(pattern) + for name in fnames: + try: + os.remove(name) + except: + continue + +f = doctest.DocTestFinder(exclude_empty=False) +runner = doctest.DocTestRunner(optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE) +objs = f.find(Tt) # list of objects with non-empty docstrings +failed = False +doctest_failed, no_doctest, no_docstring = [], [], [] +if not os.path.isdir(vcs.sample_data): + vcs.download_sample_data_files() # we need to have these for any example that uses slabs made from sample data +for obj in objs: + if obj.name.split('.')[-1][0] == '_' or obj.docstring.find('.. pragma: skip-doctest') >= 0: + continue # this is private or has been explicitly ignored; skip it. + elif obj.lineno is None: + continue # this is not actually something that can be documented; most likely came from __slots__. + if obj.docstring is '': + no_docstring.append(obj.name) # store for empty docstring warning + continue + examples = obj.examples + if len(examples) > 0: + # There are examples. Do they run? + results = runner.run(obj) + if results.failed > 0: + failed = True + doctest_failed.append(obj.name) + else: + # All docstrings not specifically skipped and non-empty require a doctest + failed = True + no_doctest.append(obj.name) +cleanup() # testing done + +# Report summary for cdash +if len(doctest_failed): + print "FAILING DOCTESTS:" + for name in doctest_failed: + print "\t" + name +if len(no_doctest): + print "MISSING DOCTESTS:" + for name in no_doctest: + print "\t" + name +if len(no_docstring): + print "NO DOCUMENTATION:" + for name in no_docstring: + print "\t" + name + +assert failed is False +print ("All doctests passed for vcs.texttable") +