pytest: invoke doctest without running unit tests

Viewed 253

I want to test an example that I just added to a docstring. I can test it by hand with the doctest module:

import doctest
import path.to.mymodule


doctest.testmod(mymodule)

but this doesn't easily iterate over all modules like pytest (and would not capture other differences in how pytest wraps it)

I can also run pytest --doctest-modules myproject/tests/ # other flags, etc. but the test suite takes roughly 20 minutes, so that's not going to work.

So I want to test the docstrings, but not wait for unit tests to run. I tried pytest -v --doctest-modules --ignore=/path/to/tests/ but it hangs and I give up after waiting a minute (collecting tests usually takes a few seconds).

I want to do this in as similar a manner as happens when pytest calls it, since that's what matters for CI.

0 Answers
Related