Run script, not non-existant unit-tests


I am writing a Python package, and have a number of test programs. They are not unit tests, and not implemented in any standard Python test framework - they are only python scripts to be executed. I am not interested in making them unit tests.

PyCharm is very helpful in allowing me to run unit tests by right-clicking. The problem is that there are no unit tests in the scripts, never have been and never will be. And whereas PyCharm makes it very easy to run the (non-existant) unit tests, PyCharm makes it exceptionally hard to just run the script - I haven't been able to figure out how to do that without jumping through hoops.

I don't know what reason PyCharm has for thinking there are unit tests in the scripts. I haven't told it, not willingly at least, and I cannot find anywhere to tell it to stop. I'd be OK with it giving me the unittest option, as long as I can still just run the script if I want to.

I am aware that I, by figuring out the file system path of a script, can create a runtime configuration specifically for that file, pasting a raw path into a dialog. I don't want to do that for every script I write - I want to right-click and choose "Run" and have the script run without fiddling with file system paths.

Google seems to imply that if I had a "__name__=='__main__'"-section, I could possibly right click there. But I don't - having one would just mean that the entire script would be indented one step for no good reason.

They're just executable scripts. How can I run them?

Comment actions Permalink
Official comment



You may create run configuration for this script and it should work.

Comment actions Permalink

I have run into this as well.  My experience was that I had a class starting with the word "Test".  Once I changed the name, the default to run the non-existent unittest went away.

Comment actions Permalink

| had exactly the same situation that Danasheahen told. I had Test class in my code. Removed it and "unit test in " disappear


Please sign in to leave a comment.