I need to be able to run all tests in the current directory by typing one line in the Linux shell. In some directories, this works fine. But in others, when I type \"nosetes
You can use --exe
in the command line to force nose to consider executables files as valid tests. If you get tired of writting --exe
everytime, you can put the line:
exe = True
in a .noserc (for unix/linux) or nose.cfg (for windows) file at yout home directory.
From Python Testing: Beginner's Guide by Daniel Arbuckle:
Nose looks for tests in directories and modules whose names start with
test
andTest
, or contain a'_'
,'.'
, or'-
' followed bytest
orTest
. That's the default, but it's not actually the whole story.
An Extended Introduction to the nose Unit Testing Framework shows that you can see a verbose output from nose's test discovery algorithm by running:
nosetests -vv --collect-only
When I ran the above on a directory, I noticed that Nose skips executable files. If that's your problem, you'll need to change the file mode to non-executable. On Mac OS X or Linux, this can be accomplished with:
chmod 644 file.py
or similar.
If you know that your modules/files are import-safe, then you can run Nose with the --exe
option to "look for tests in python modules that are executable" (from `man nosetests):
nosetests --exe