15

I can run tests in workflow folder with nosetests:

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

OK

my tests live in test folder:

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

But when I move to parent dir:

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

It cannot find tests.

(py3env)Makss-Mac:Packages maks$ nosetests

----------------------------------------------------------------------
Ran 0 tests in 0.005s

OK

So how to make nosetest search tests in all subdirectories?

Maxim Yefremov
  • 13,671
  • 27
  • 117
  • 166

2 Answers2

18

If you make your workflow folder a module by placing __init__.py in it, nose should be able to find your tests.

Oleksiy
  • 6,337
  • 5
  • 41
  • 58
7

If you don't want to make your folder a module, put a setup.cfg in the directory you want to run nosetests which automatically passes the tests option to nosetests to specify relative location of tests. Like so:

#setup.cfg contents:

[nosetests]
exe = True
tests = workflow/

You can also pass multiple folders/tests using this same mechanism:

#setup.cfg contents:

[nosetests]
exe = True
tests = workflow/, other/dir/full/of/tests/, direct/file/my_test.py
7yl4r
  • 4,788
  • 4
  • 34
  • 46