Friday, April 18, 2014

Python nose testing

Nose provide additional testing functionalities that are not provided in unittests framework. Unlike unittests which is a standard python module you will have to easy_install nose as described here.


use test_mytest.py to name a test module and test_method to name any test methods. If you do so the nosetests will be able to discover and execute those tests automatically.

You will have to use assert_equal(A, B) to test whether A is equal to B.
For numpy arrays use numpy.testing.assert_array_equal instead to compare numpy arrays.

To test the unit tests you must call nosetests as follows.

To display the name of the test functions
nosetests -v test.py

To display the print statements as well
nosetests -v -s test.py

Execute a specific test function within a class in a test module
nosetests -v -s test.py:className:test_method 
 

Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1