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?
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.
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.
Remove the @pytest. mark. skip mark from test_primary_guardian and the test now passes.
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
In my case I had configuration set to > Test: Class
Once changed to Script it works without splashing any errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With