How to run the doctest for a single function in python3?


How do I run the doctest for only a single function in python using the command line? I can python3 -m doctest -v but this will run all the doctests in How do I specify one function to call the doctest on?

Asked By: Shams Ansari



That depends on the code in that runs the doctests. You can change that code to test a specific function by calling doctest.run_docstring_examples().

When that code runs doctest.testmod() however, you cannot limit testing to a single function from the command line.

Answered By: René Pijl

You can accomplish this using my doctestfn package:

pip install doctestfn

It can then be used to run tests for a single function in a module as follows:

doctestfn myfunction
Answered By: jncraton
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.