PyCharm 4 - Go To -> Test - populates test class as unittest, not nose

Hi, I'd like to configure PyCharm to generate test stubs for nose instead of unittest.

I've searched the forum and couldn't find anyone who had already asked this, and have also checked StackOverflow.

I am developing tests using nose, and am able to tell PyCharm that it should use nosetest as my test runner, the tests are invoked correctly and all is good.

However, I would like to use the convenience helper to create a stub test class and test methods using the (Right-click on target for the tests) Go To -> Test -> Create new test facility (or CTRL+SHIFT+T).

This works, but creates a stub test class that is specific to unittest and not nose.

I've told PyCharm to use Nosetests as my Default test runner in Settings -> Tools -> Python Integrated Tools.

Is this a limitation of the feature - i.e. it only builds a unittest stub even though I've configured PyCharm to use nosetests)?

Is there a template file I can edit to populate the stub use nose-specific terminology?

Any guidance gratefully received.

Thanks.
5 comments
Comment actions Permalink
Anyone got any ideas?

Thanks.
0
Comment actions Permalink
You can set the stubs in settings/File and Code Templates in the IDE section of the Settings window.  I presume this is what you're looking for.

An alternative that I use so I can switch easily between the outputs is to use unittest and set the verbosity level to 2, this is the equivalent to what nose outputs.  Of course, that would depend on what you are looking for from nose.
test_runner = unittest.TextTestRunner(descriptions=False, verbosity=2)
0
Comment actions Permalink
@Randolph, many thanks for the reply, but I think we're talking about different things.

The File and Code Templates in the settings seem to change the code that is populated in the editor when you do File -> New... -> Python File. You're then asked for the filename, and you can select the type of Python file - and it's here where you can select Python Unittest.

Instead, I'm talking about the ability to generate a test stub code using the Go To -> Test context menu in the editor (CTRL+SHIFT+T). You position the cursor on the class/function and do Go To -> Test.

You can then create a new test and it brings up a dialogue like this.

2014-12-06_10-33-19.png


It then goes on to create some stub test code for the selected methods of the class that is based around unittests: Like so...

from unittest import TestCase

class TestMessageManager(TestCase):
    def test_reset(self):
        self.fail()

    def test_collate(self):
        self.fail()

    def test_send(self):
        self.fail()


I'd like it to generate a nosetests-specific stub, but I can't see where the template might be stored. Is it in the template and code section you mentioned? If so, can you point me to where it is?

Thanks for the suggestion.
0
Comment actions Permalink
Please vote for this request in YouTrack: https://youtrack.jetbrains.com/issue/PY-15021.
0

Please sign in to leave a comment.