Newbie Q: I'm not able to use pytest

Answered

I'm completely new to PyCharm and I'm trying to brush up on my Python. My problem is that I want to use pytest but for some reason I can't get PC to use it.

What I've done is that I've set the preferences Default test runner in Tools > Python Integrated Tools to py.test. When I first did this I got a warning that it wasn't available, I clicked "fixit" and the error messages disappeared. I then go to one method I want to test and hit shift-command-T, I create a new test class ... and the first line I get in the resulting file is "from unittest import TestCase".

Being completely new to pytest also I assume this is wrong, since this indicates to me that I'm using the standard unittest module.

What am I missing? I assume it's something basic but what?

 

0
1 comment

pytest can actually use the UnitTest assertions, under the pytest test runner. See the FAQ entry for some explanation.

You're right that our automatic generation of tests via refactoring don't write pytest-style tests, even when you choose pytest as your project's test framework. I believe this ticket covers what you are looking for, so you could go vote for that ticket.

1

Please sign in to leave a comment.