Run nosetests in all subdirectories

I can run tests in the workflow folder using nosetests :

 workflow maks$ nosetests .......... ---------------------------------------------------------------------- Ran 10 tests in 0.093s OK 

my tests live in the test folder:

 workflow maks$ ls __pycache__ iterations.py test data iterationsClass.py testData env iterationsClass.pyc 

But when I go to the parent directory:

 (py3env)Makss-Mac:workflow maks$ cd .. 

Cannot find tests.

 (py3env)Makss-Mac:Packages maks$ nosetests ---------------------------------------------------------------------- Ran 0 tests in 0.005s OK 

So how to do nosetest search tests in all subdirectories?

+7
python nose
source share
2 answers

If you add a module to the workflow folder by placing __init__.py in it, the nose will have to find your tests.

+10
source share

If you do not want your folder to be a module, place setup.cfg in the directory you want to run nosetests , which automatically passes the tests parameter to nosetests to indicate the relative location of the tests. For example:

 #setup.cfg contents: [nosetests] exe = True tests = workflow/ 

You can also transfer multiple folders / tests using the same mechanism:

 #setup.cfg contents: [nosetests] exe = True tests = workflow/, other/dir/full/of/tests/, direct/file/my_test.py 
+2
source share

All Articles