I use nosetests
to run my unittests and it works well. I want to get a list of all the tests nostests
finds without actually running them. Is there a way to do that?

- 42,563
- 25
- 88
- 99
3 Answers
Version 0.11.1 is currently available. You can get a list of tests without running them as follows:
nosetests -v --collect-only

- 38,641
- 34
- 96
- 120
-
3See [`-vv`](http://stackoverflow.com/a/3448487/232794) as a better option than `-v`. – Sardathrion - against SE abuse Sep 27 '12 at 10:18
-
`nosetests -v --collect-only | grep 'some-string'` is not working. Any idea why? – Eyal Levin Jan 11 '17 at 17:07
-
@EyalLevin I ran into the same thing. The output goes to stderr, so you need to do `nosetests -v --collect-only 2>&1 >/dev/null | grep 'some-string'` – sihrc Feb 09 '18 at 19:09
I recommend using:
nosetests -vv --collect-only
While the -vv
option is not described in man nosetests
, "An Extended Introduction to the nose Unit Testing Framework" states that:
Using the -vv flag gives you verbose output from nose's test discovery algorithm. This will tell you whether or not nose is even looking in the right place(s) to find your tests.
The -vv
option can save time when trying to determine why nosetests is only finding some of your tests. (In my case, it was because nosetests skipped certain tests because the .py
scripts were executable.)
Bottom line is that the -vv
option is incredibly handy, and I almost always use it instead of the -v
option.

- 457,139
- 39
- 126
- 163
There will be soon: a new --collect
switch that produces this behavior was demoed at PyCon last week. It should be on the trunk "soon" and will be in the 0.11 release.
The https://groups.google.com/g/nose-users list is a great resource for nose questions.

- 6,183
- 4
- 39
- 52