I want to start writing unit tests for my Python code, and the py.test framework sounds like a better bet than Python’s bundled unittest. So I added a “tests” directory to my project, and added test_sample.py to it. Now I want to configure PyCharm to run all the tests in my “tests” directory.
PyCharm allegedly supports py.test in its test runner. You’re supposed to be able to create a run/debug configuration to run your tests, and PyCharm allegedly has a “create configuration” dialog box specifically for py.test. But that’s the complete extent of their documentation on the subject, and I can’t find this alleged dialog box anywhere.
If I right-click the directory in the Project tool window, I’m supposed to see a “Create <name>” menu item, but the only menu item starting with “Create” is “Create Run Configuration”. Okay, maybe the documentation is just wrong, and “Create Run Configuration” does sound promising. Unfortunately, the only two items in its submenu are “Unittests in C:/mypath…” and “Doctests in C:/mypath…”, neither of which applies — I’m using neither unittest nor doctest. There is no menu item for py.test.
If I open my test_sample.py and right-click in the editor window, I do get the promised “Create <name>” menu items: there’s “Create ‘Unittests in test_sa…’…”, followed by “Run ‘Unittests in test_sa…'” and “Debug ‘Unittests in test_sa…'”. So again, it’s all specific to the unittest framework; nothing for py.test.
If I do try the menu items that say “unittest”, I get a dialog box with options for “Name”, “Type”, a “Tests” group box with “Folder” and “Pattern” and “Script” and “Class” and “Function”, etc. This sounds exactly like what’s documented as the dialog to add a configuration for Python Unit Test, and not like the “Name” and “Test to run” and “Keywords” options that are supposed to show up in the configuration for py.test dialog. There’s nothing inside the dialog to switch which test framework I’m adding.
I’m using PyCharm 1.5.2 on Windows with Python 3.1.3 and pytest 2.0.3. I can successfully run py.test on my tests from the command line, so it’s not something simple like pytest not being installed properly.
How do I configure PyCharm to run my py.test tests?
How to configure pycharm / intellij idea to run tox tests
Is it possible to configure pycharm / intellij idea to run tox tests? I want to test my code against different python versions in separated py environments. I was trying to configure it, but so far I
How do I configure pycharm to “gray out” excluded folders?
How do I configure pycharm to gray out excluded folders rather than just removing them from the project view?
How do you run nosetest from pycharm?
How do you execute nosetest from pycharm to run all unit tests? I know that pycharm supports python’s unittest and py.test and that they will properly support nosetests in pycharm 1.1 but I was wonder
How do I configure Eclipse to run your tests automatically?
I read this article: Configure your IDE to run your tests automatically http://eclipse.dzone.com/videos/configure-your-ide-run-your It’s pretty easy to configure Eclipse IDE to run an Ant target every
PyCharm: how to run tests in all open projects?
I would like to set a configuration in PyCharm, that runs tests (e.g., nosetests) in several open projects. How can I do this? I’m using PyCharm 2.6.2 on Windows.
Pycharm autocomplete pytest [closed]
Is it possible to enable pytest autocompletion in PyCharm 2.7.3? The problem is that pytest.py looks like this: … # we are simply imported from _pytest.core import main, UsageError, _preloadplugins
How do I run the GruntJS tests?
I just cloned the gruntjs repository. How do I actually run the tests for GruntJS? (I don’t mean I want to run my own tests using GruntJS. I mean that I want to run the tests for GruntJS itself.)
How do I force pytest to write color output?
How do I force pytest to show the results in color, even when writing to a pipe? There does not seem to be any command line option to do so.
how do i run phpunit tests?
https://github.com/phpseclib/phpseclib/tree/master/tests My familiarity with phpunit is pretty lacking. How do I run those tests? I installed phpunit using the following commands (per this website): p
Pytest: Deselecting tests
With pytest, one can mark tests using a decorator @pytest.mark.slow def some_slow_test(): pass Then, from the command line, one can tell pytest to skip the tests marked slow pytest -k-slow If I hav
I think you need to use the Run/Debug Configuration item on the toolbar. Click it and ‘Edit Configurations’ (or alternatively use the menu item Run->Edit Configurations). In the ‘Defaults’ section in the left pane there is a ‘py.test’ item which I think is what you want.
I also found that the manual didn’t match up to the UI for this. Hope I’ve understood the problem correctly and that helps.
Please go to Settings | Python Integrated Tools and change the default test runner to py.test. Then you’ll get the py.test option to create tests instead of the unittest one.
It’s poorly documented to be sure. Once you get add a new configuration from defaults, you will be in the realm of running the “/Applications/PyCharm CE.app/Contents/helpers/pycharm/pytestrunner.py” script. It’s not documented and has its own ideas of command line arguments.
- Try to play around, reverse the script, and see if you can somehow get py.test to accept arguments. It might work; it didn’t in the first half hour for me.
- Just run “py.test *.py” from a console.
Oddly, you will find it hard to find any discussion as JetBrains does a good job of bombing Google algorithms with its own pages.
With a special Conda python setup which included the pip install for py.test plus usage of the Specs addin (option –spec) (for Rspec like nice test summary language), I had to do ;
1.Edit the default py.test to include option= –spec , which means use the plugin: https://github.com/pchomik/pytest-spec
2.Create new test configuration, using py.test. Change its python interpreter to use ~/anaconda/envs/ your choice of interpreters, eg py27 for my namings.
3.Delete the ‘unittests’ test configuration.
4.Now the default test config is py.test with my lovely Rspec style outputs. I love it! Thank you everyone!
p.s. Jetbrains’ doc on run/debug configs is here: https://www.jetbrains.com/help/pycharm/2016.1/run-debug-configuration-py-test.html?search=py.test