If I have a file beginning with "test_", PyCharm tries to run this with PyTest. I want to run it normally (as a regular Python script). How can I do this?
Edit with Solution: As A. Romeau pointed out, there are ways to do this:
For a given test file that you want to run normally:
- Run the file... note that it runs under py.test or some other testing framework.
- Click on the drop-down box on the top-right that says something like "py.test in test_something.py".
- Click "Edit Configurations". This will open a window with "Python" and "Python tests" as options on the left. You'll notice you're in the "Python tests" section.
- Copy the file path in the "Target:" field.
- Click the red "-" in the top left, which will remove that test configuration.
- Now, click the green "+", select "Python", and paste the file path you copied in the "Script:" field.
- Press "OK". Your test file will now run as an ordinary script.
Edit your setup.cfg file in pytest (with some option that I don't know right now) so that it doesn't "discover" your test (I have not tried this).
Neither solution is good. 1 is inconvenient because you need to go through a big mutli-click and process for each file you might want to run like this. 2 is inconvenient because it interferes with you running pytest normally, from console.
JetBrains: Please for the love of God just add an option to disable automatic unittesting. It is very annoying because the output of pytest/UnitTest is not nearly as helpful as the output of the regular interpreter when trying to track down bugs in tests (no links to the failing line, can't easily run given function alone, etc).
A PyCharm "issue" has been opened here.