How do you run nosetest from pycharm?

Viewed 20769

How do you execute nosetest from pycharm to run all unit tests?

I know that pycharm supports python's unittest and py.test and that they will properly support nosetests in pycharm 1.1 but I was wondering if there was a work around.

3 Answers

This is easy to accomplish....

I assume you have nose already installed.

And that your project looks like

   \MyProj_Source
      \MyProj
          init.py
          MyProj.py

We need to Create a Tests directory (Yes the name seems to be critical). And in that Tests folder we place our nose test file. So the Directory structure looks like this.

   \MyProj_Source
      \MyProj
          init.py
          MyProj.py
       \Tests
          test_stuff.py

At this point you need to go to

Preferences-> Tools -> Python Intergrated Tools ** and set **Default Test Runner to be nose

You should now be able to

Manually

  • Run test_stuff.py using nose
  • Enable Auto Testing for the file MyProj.py so after any change the tests are run

The 2nd way is the best option, but it can be a little time consuming.

Hope that helps.

Related