Disable Pytest in PyCharm

If I have a file starting with "test_", PyCharm tries to run this with PyTest. I want to run it normally (like a regular Python script). How can i do this?

Change using solution: As A. Romau noted, there are ways to do this:

  • For this test file that you want to run normally:

    • Run the file ... note that it works under py.test or some other testing environment.
    • Click on the dropdown in the upper right that says something like "py.test in test_something.py".
    • Click "Edit Configurations." This will open a window with the parameters "Python" and "Python tests" as parameters on the left. You will notice that you are in the "Python Tests" section.
    • Copy the path to the file in the "Target:" field.
    • Click the red “-” in the upper left corner, which will remove this test configuration.
    • Now click green "+", select "Python" and paste the path to the file that you copied into the "Script:" field.
    • Click OK. Your test file will now work as a regular script.
  • Change the setup.cfg file in pytest (with some option that I don’t know right now) so that it doesn’t “detect” your test (I haven’t tried this).

None of the solutions are good. 1 is inconvenient because you need to go through a big click and process for each file that you might want to run this way. 2 is inconvenient because it prevents you from starting pytest normally from the console.

JetBrains: Please, for the love of God, simply add an option to turn off automatic deletion. This is very annoying, because the output of pytest / UnitTest is not as useful as the output of a regular interpreter when trying to track errors in tests (there are no links to the error string, it cannot easily run this function alone, etc.).

The "PyCharm Problem" was discovered here .

+4
source share
1 answer

You can create a launch configuration for this specific file in the "Run / Edit Configurations" section or change the test detection settings for py.test, therefore files starting with test_ * are not considered test files by default.

Further information here:

http://pytest.org/2.2.4/example/pythoncollection.html

+1
source

Source: https://habr.com/ru/post/982375/


All Articles