fnlCtrl
fnlCtrl

Reputation: 111

Pycharm 4.0.4 cannot run file, shows 'Run Doctests' in context menu instead

I have copied a .py file from my teacher, and loaded it in to a project in Pycharm 4.04. When i tried to right-click and run it, it shows "Run Doctests in 'foo.py'" instead of the regular "Run 'foo.py'", and i cannot find out how to run it normally.

I searched for 'doctest' in settings and found nothing, and in PyCharm documentation here, there's nothing about disabling doctests either.

I found a similar question here: Pycharm won't allow to run a file. Shows run unittest option only. and tried the suggested solution, but it still showed "Run doctests in 'foo.py'" in context menu.

Upvotes: 11

Views: 2531

Answers (3)

Mine is PyCharm 2023.2 (Community Edition) and if I right click inside the if __name__ == '__main__' block there is a Run "filename" option. Outside you can just start the Docstring tests.

Thanks to @Mehraban who mentioned in the comment above.

Upvotes: 0

Darkonaut
Darkonaut

Reputation: 21654

Just had the same issue. In my case, I had a '>>>' string within the docs of a function:

def foo(x):
    """Do foo.
    Example:
    >>>foo(1)
    # Out: 1
    """
    return x

I had to comment out # >>>foo(1) and delete the run config under Run > Edit Configurations (minus symbol).

Upvotes: 10

Paul W
Paul W

Reputation: 153

I'm having the same Run 'Doctests in __init__' issue with PyCharm 2016. I'm not sure if this is due to the same problem other people are having, but this is my fix.

I noticed the file that won't run lives in a resource directory:

click here for image

Once I opened a new PyCharm project with the script I want to run not in a resource directory, PyCharm ran it with no problem.

Upvotes: 4

Related Questions