I want to start writing unit tests for my Python code, and py.test is a better bet than Python in unittest . So I added the "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 supposedly supports py.test in its test runner. You must create a run / debug configuration to run your tests, and PyCharm supposedly has a โcreate configurationโ specifically for py.test . But what is their full documentation on this subject, and I cannot find this prospective dialog box anywhere.
If I right-click the directory in the Project tool window, I assumed to see "Create <name>"; but the only menu item starting with "Create" is "Create Startup Configuration". Well, maybe the documentation is just wrong, and "Create Run Configuration" sounds promising. Unfortunately, there are only two items in his submenu - "Unittests in C: \ mypath ..." and "Doctests in C: \ mypath ...", none of which apply - I do not use either unittest or doctest. There is no menu item for py.test.
If I open my test_sample.py and right-click in the editor window, I will get the promised "Create <name>"; menu items: "Create" Unittests in test_sa ... "...", then "Run" Unittests in test_sa ... "and" Debug "Unittests in test_sa ...". So again, all this relates to a unitary structure; nothing for py.test.
If I try menu items that say "unittest", I get a dialog box with the options "Name", "Type", the "Tests" field with "Folder" and "Template" and "Script" and "Class" and "Function" etc. This sounds exactly the same as in the dialog box to add the configuration for the Python Unit Test ., And not like the Name and Test to Run and Keywords parameters that should be displayed in the configuration for py.test . There is nothing in the dialog box to switch the check frames that I add.
I am using PyCharm 1.5.2 for Windows with Python 3.1.3 and pytest 2.0.3. I can successfully run py.test in my tests from the command line, so it's not as simple as pytest, which is not installed properly.
How to configure PyCharm to run my py.test tests?
Joe White Jun 18 '11 at 15:37 2011-06-18 15:37
source share