New submission from R. David Murray: I propose that we remove the paragraph before 'run_docstring_exmaples' in the doctest docs. It says that there's no intent to remove the function but that it is "rarely useful". However, it is in fact *very* useful, for any code that also uses testmod.
For example, a module I just wrote has this: if __name__ == '__main__': import doctest flags = doctest.REPORT_NDIFF|doctest.FAIL_FAST if len(sys.argv) > 1: name = sys.argv[1] if name in globals(): obj = globals()[name] else: obj = __test__[name] doctest.run_docstring_examples(obj, globals(), name=name, optionflags=flags) else: fail, total = doctest.testmod(optionflags=flags) print("{} failures out of {} tests".format(fail, total)) This makes the module its own test runner: if I get doctest failures, I can re-run a *specific* doctest while debugging the problem, and is the obvious application of run_docstring_examples. The attached patch also clarifies the fact that it works on strings. It also adds the above example to the soapbox section of the docs. I'm less interested in that change than in the clarification that strings work :) Someday perhaps I'll propose the addition of the equivalent to unittest.main for doctest. ---------- files: remove_doctest_run_docstring_examples_gloss.patch keywords: patch messages: 247667 nosy: r.david.murray priority: normal severity: normal stage: patch review status: open title: doctest run_docstring_examples does have an obvious utility type: enhancement versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6 Added file: http://bugs.python.org/file40067/remove_doctest_run_docstring_examples_gloss.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24756> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com