Disable automatic recycling in PyCharm

PyCharm automatically detects when files start with test_ , and tries to run them as Unittests. Which is very important, but something seems broken, and with any test that I run, I get

 /Users/peter/projects/plato/venv/bin/python2.7 "/Applications/PyCharm CE.app/Contents/helpers/pycharm/utrunner.py" /Users/peter/projects/plato/utils/tools/test_sampling.py::::test_samplers_not_broken true Testing started at 10:58 AM ... Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/helpers/pycharm/utrunner.py", line 140, in <module> all.addTest(testLoader.makeTest(getattr(module, a[2]))) AttributeError: 'TestLoader' object has no attribute 'makeTest' Process finished with exit code 1 

All I want to do is run them like regular python files, but PyCharm will not let me. Eclipse makes it possible to start normally or run as unittest. This is annoying! How can i do this?

Decision

While it is displayed, you cannot disable this option globally; you can prevent individual files from running as tests. For an answer see this question .

+6
source share
3 answers

Click here (a small gray arrow pointing next to the settings button on the toolbar above the editor) Select "Change Configuration"

There you can choose which tests to run pycharm and when. Perhaps the All in folder button is installed there, select another option, for example, a script

You should also check the bottom of your file after if __name__ == '__main__'

Perhaps you have code that automatically runs a test when this file is run.

+4
source

In my case, I had a setting on> Test: Class

After changing to Script, it works without bursts of errors.

Screen shot

+2
source

My temporary solution is to add a block at the bottom of the page.

if __name__ == "__main__": pass

To the left of the block in the fields there will be a button to run the script without testing.

enter image description here enter image description here

Alternatively, you can track this issue here .

Note: If the files or functions in the file begin with test_ , then PyCharm tries to run the default Unittests scripts .

UPD 01/31/2018: I tried to take an example of how it works for me.

enter image description here

In addition, you can always see the parameters without a block with if ( Shift+Alt+F10 )

enter image description here

-1
source

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


All Articles