How to run doctests


I have a number of files with embedded doctests. Their configurations are identical. Yet in some, right-clicking the file offers to

run/debug 'Doctests'

whereas in others those menu positions simply offer to

run/debug <filename>

How can I run doctests when that option isn't listed in the menu?




Hi Russ,

Thank you for contacting PyCharm support.

Please see


If it doesn't answer your question, please provide a project sample (can be uploaded to as zip file), if possible. Please let us know the name of the zip file afterwards.

Kind regards,


The Drive to Develop


Thanks, but it didn't help.  I am trying to do something extremely simple. I opened a file called gridWorld in PyCharm. When I right-click, the only run/debug option I get are to run/debug Doctests in gridworld, not run/debug gridWorld. I was able to copy the contents of the file to another file called gridWorld2, which I could run. That's the configuration you see at the upper right. But that configuration drop down has no other options.  

I am able to run the file by going to terminal mode and then running 
> python
So why can't I do the equivalent from the standard view?
Copies of both gridWorld and gridWorld2 will be uploaded to your link above.
-- Russ

Oh, now I see what you mean.

It means that it currently doesn't have any other run configuration.

Please try alt+shift+f10 for Windows or ctrl+alt+r for Mac OS, select run configuration and hit Enter.

After that you can either right click the file and run it, or use corresponding buttons.

See for more information about Run/Debug Configuration.


Thanks! That did it -- although I was still confused until the end.  I did alt+shift+f10 and then hit Enter. Nothing seemed to happen! So I tried it again and found that the Doctests line I just clicked was missing. Then, right clicking let me run the file.

I appreciate the help, but why make things so difficult? Also, is there some way to get the same effect as alt+shift+f10 without having to remember that key combination?


Yes, it can also be done from the menu by going to `Run | Run...`. You can also customise the shortcuts as you wish.


Please sign in to leave a comment.