5

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?

mit
  • 11,083
  • 11
  • 50
  • 74
eretmochelys
  • 543
  • 1
  • 5
  • 15
  • sorry, this is almost a duplicate of https://stackoverflow.com/questions/17056138/how-to-make-py-test-run-doctests-as-well-as-normal-tests-directory – eretmochelys Dec 26 '17 at 22:51
  • this question is dfferent, it is about pycharm, the other one is not – mit Oct 31 '20 at 19:26

1 Answers1

5

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.

asherbret
  • 5,439
  • 4
  • 38
  • 58