2

Let's say I have an app.py file with the following contents:

def foo(): return 'bar' 

Even with py.test set as a default test runner in PyCharm (Settings -> Tools -> Python Integrated Tools), PyCharm always generate unittest-like tests (right-click on a function name -> Go To -> Test -> Create New Test), eg.:

from unittest import TestCase class TestFoo(TestCase): def test_foo(self): self.fail() 

I can change Python Unit Test template in Setting -> Editor -> File and Code Templates, but it only has effect when creating new file (New -> Python File -> Kind: Python unit test).

I would like the generated tests to be more py.test-like:

def test_foo(): assert False 

Even better would be to have proper imports already placed in:

from my_app import foo def test_foo(): assert False 
1
  • I just stumbled into this one. I'd finally made the switch from unittest and was going insane trying to figure out why Generate Test wouldn't honour my setting to pytest as test runner. :( Commented Apr 27, 2019 at 8:34

1 Answer 1

1

Unfortunately, it's not possible. Please vote for the corresponding feature request in PyCharms' bug tracker: PY-15021.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.