2

I was wondering this already for a while now, but I was not able to figure out how to pass options to nosetests to run different tests which reside in different sub-directories. Example of an package directory structure:

my_package/
|-- my_module1/
   |-- tests/
       |-- unit/
           | ... a bunch of unit tests
       |-- integration/
           |... a bunch of integration tests
|-- my_module2/
   |-- tests/
       |-- unit/
           | ... a bunch of unit tests
       |-- integration/
           |... a bunch of integration tests

If I want to execute just the unit tests in all my modules (all the tests in tests/unit/ sub-directories), how would I do that using the nosetests library?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Torsten Engelbrecht
  • 13,318
  • 4
  • 46
  • 48

1 Answers1

2

I think --where or --match nosetests arguments can help you:

-w WHERE, --where=WHERE Look for tests in this directory. May be specified multiple times. The first directory passed will be used as the working directory, in place of the current working directory, which is the default. Others will be added to the list of tests to execute. [NOSE_WHERE]

-m REGEX, --match=REGEX, --testmatch=REGEX Files, directories, function names, and class names that match this regular expression are considered tests. Default: (?:^|[\b_./-])[Tt]est [NOSE_TESTMATCH]

Also, see Anyone know how nosetest's -m, -i and -e work?

But, actually, I prefer to have tests dir at the root level: How to organize and run unittests and functional tests separately using nosetests

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Thanks, the point is that I don't want to specify each directory one by one when passing the `-w` option (assuming I have a huge project). I looked into `-m` as well, but couldn't figure it out so far. I guess I have to dig a little deeper. – Torsten Engelbrecht Mar 21 '13 at 10:08