George V. Reilly

Nosetests won't discover tests in executable files

Nose is nicer testing for Python

We use Nose to run unit tests. I noticed that we had some tests that weren’t being run, and it took me some time to work out why. Eventually, I found this checklist, which told me to "make sure the files in your tests directory are not executable".

A quick chmod -x *.py later and nosetests project/tests suddenly found all the tests.

Now that I know what to look for, I found this in the Nose docs:

It is important to note that the default behavior of nose is to not include tests from files which are executable.

--exe: Look for tests in python modules that are executable. Normal behavior is to exclude executable modules, since they may not be import-safe

blog comments powered by Disqus
Review: Blood Eye » « George Clery, died 3rd March 1965