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.
nose can be integrated with DocTest by using with-doctest option in athe bove command line. The result will be true if the test run is successful, or false if it fails or raises an uncaught exception. nose supports fixtures (setup and teardown methods) at the package, module, class, and test level.
In the current version of Pycharm (2.6) there should be a context menu "run Nosetests in ..." on a test file. If this is missing, go to file->settings->Project Settings->python integrated tools
and ensure the Default Test Runner is Nosetests. You do of course need to have Nosetests installed - pycharm will offer this if you do not.
This does have a limitation. If the file in question does not have a class derived from unittest.TestCase it will not automatically show this. If you are using nose.tools or simple assertions it will not automatically offer this. This is probably a bug.
If you can live without the graphical test runner, you can simply create a "Python Script" run configuration and run the tests as you run them from the command line.
The only way to get nose tests working with the graphical test runner, I'm afraid, is to hack on helpers/pycharm/utrunner.py from the PyCharm distribution.
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
The 2nd way is the best option, but it can be a little time consuming.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With