Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Automatic unittesting in PyCharm

Tags:

pycharm

PyCharm automatically detects when files begin with test_, and tries to run them as Unittests. Which is very considerate, but something seems to be broken, and on any test 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 as normal python files, but PyCharm won't let me. Eclipse gives the option to run normally or run as unittest. This is annoying! How can I do this?

like image 971
Peter Avatar asked Feb 12 '15 10:02

Peter


People also ask

How do I set the default test runner in PyCharm?

To set a test runner, press Ctrl+Alt+S to open the IDE settings and select Tools | Python Integrated Tools, and then select the target test runner from the Default test runner list.

How do I run a single Testcase in PyCharm?

PyCharm makes it easy to select just one test to run. In fact, there are several ways to do it: With the cursor anywhere in the test you want to focus on, right-click and choose to run that in the test runner. Right-click on the test in the test tool listing and choose to run it.

How do I skip a test in PyCharm?

Remove the @pytest. mark. skip mark from test_primary_guardian and the test now passes.


2 Answers

Press here (small gray arroy pointing down near settings button on tools panel above editor) Choose 'Edit Configuration'

There you can choose what tests pycharm should run and when. Probably there set All in folder button, choose another option like script

Also you should check bottom part of your file, after if __name__ == '__main__'

maybe you have code there that automatically launches test when you run this file

like image 68
micgeronimo Avatar answered Nov 15 '22 06:11

micgeronimo


In my case I had configuration set to > Test: Class

Once changed to Script it works without splashing any errors.

Screenshot

like image 40
Gunay Anach Avatar answered Nov 15 '22 06:11

Gunay Anach