Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run all doctests in a folder recursively in pycharm?

Tags:

Pycharm is great for running all of the doctests per (script / function / class / folder*) but the folder option runs all doctests which are immediately within that folder (not within folders of that folder).

Is there a way to recursively run through some top level folder and run all doctests found?

like image 231
eretmochelys Avatar asked Dec 25 '17 13:12

eretmochelys


1 Answers

This can be done from PyCharm with the help of pytest:

  1. If you don't already have it, install pytest by running pip install -U pytest
  2. In PyCharm go to Run --> Edit configurations
  3. Add a new configuration by clicking the + button
  4. From the pop-up menu, choose Python tests --> py.test
  5. Add --doctest-modules to the Additional Arguments field
  6. Click OK

Now running the newly created configuration will discover and run all doctests, even those in subdirectories.

See PyCharm's documentation for more configuration options.

like image 80
asherbret Avatar answered Sep 20 '22 12:09

asherbret