Reputation: 71
I am working on writing tests for my python code. I explored unit tests and decided to use PyTest. I am using PyCharm for my IDE to run/debug my python code.
However, when I run the test file that I created, it does not output anything in the PyCharm output. I have read about similar issues here. As a result, I went into the PyCharm preferences and changed the default testing from unit test to PyTest. However, this did not seem to fix the problem. I am a little unsure of how to get this to display the desired output. I imagine if I were to run this in the terminal the output would display properly. I am just having trouble seeing it in PyCharm.
Although it is not really relevant, the python code file I am testing is a simple definition of a function that computes the fibonacci sequence. The test file, aptly named, test_fib then tests it. Everything runs properly, but the traditional PyTest output (all tests passed etc.) is not displaying.
Any suggestions? I can add additional information or details if necessary.
Thanks.
EDIT:
I have included a snapshot to illustrate more or less the expected output:
Upvotes: 0
Views: 3230
Reputation: 150
Considering you've changed the default runner to pytest, per your reference, new "Configurations" should now use that setting. However, old/existing ones will not.
Change the Default test runner
Assuming you've already done this, but for completeness sake:
File
> Settings
Tools
> Integration Tools
Default test runner
, change it to pytest
OK
Recreating a Configuration
To delete an existing Configuration:
Run
> Edit Configurations
. This should bring up the "Run/Debug Configurations" dialog box.-
icon on the upper-left corner of the "Run/Debug Configurations" dialog box.OK
on the bottom-right corner of the dialog box.To create a new Configuration:
Run 'pytest in <your pytest file name>...'
More information about Configurations
These are my Configurations:
Notice:
When a pytest Configuration is run, it should look something like this:
References
JetBrains' PyCharm/Pytest help page: https://www.jetbrains.com/help/pycharm/pytest.html
Side Note
In addition, notice one of the comments in the link you provided suggests manually creating a pytest configuration. That, technically, answers your question, too.
Upvotes: 5