Mac OS - PyCharm 2017 running file as unittest when not

Answered

I have a file that I call test_sim.py (I've also renamed it to 'testsim.py'). When I hotkey run script (shift + control + R) pycharm runs this file as a unittest. It's not a unittest. I'm simply running my file called sim.py with various inputs. If I go to 'Edit Configurations...', I also see every file I've run previously. When I erase the unittest configurations, then go to the `if __name__=='__main__'` and right click to run the file, it runs properly. But after I do that if I hotkey run it, it goes back to a unittest run. I also noticed that in the 'Edit Cofigurations...' I see every file I've previously run. 

I want to be able to run files starting with the word 'test' or 'test_' not as a unittest file. How can I achieve this? How can I configure pycharm to not unittest unless I specifically configure the file to be a unittest file? And lastly, how do i setup the configurations to only have one function called "Run" that will run each file the same and not make new run configs?

A lot has changed for me when I updated to the 2017 version of pycharm. I had just purchased a new computer, and had to install all the dependencies I need. I decided to also update pycharm to the 2017 version. So, this may not be a 2017 issue. Previously I didnt have this issue. And I don't believe PyCharm kept a running log of each file I ran. Maybe it did, because I do recall seeing the name of the file at the dropdown when I ran it. 

0
1 comment
Official comment

Hello.

Since 2017.1 you may choose between using unittest and plain runner. When you click CTRL+Shift+F10 PyCharm suggests you list of available runners giving you ability to choose one. Once chosen in creates configuration for this file and reuses it each time for this file so you would not need to choose runner again.

It is improssible now to configure PyCharm to automatically run all test* files as plain python files, but there is an issue which you can vote and track: https://youtrack.jetbrains.com/issue/PY-20521

Thank you.

Please sign in to leave a comment.