Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does nose finds tests in files with only 644 permission?

Today I ran a bunch of doctests using Python 2.6 on a Ubuntu 9.10 with nose :

nosetests --with-doctest
Ran 0 tests in 0.001s

OK

WTF? I had tests in that files, why didn't that work?

I changed permission to 644:

sudo chmod 644 * -R
nosetests --with-doctest
Ran 11 test in 0.004s

FAILED (errors=1)

Changing it back to 777:

sudo chmod 777 * -R
nosetests --with-doctest
Ran 0 tests in 0.001s

OK

Why is that? Using 644, I can't even edit my files!

like image 684
e-satis Avatar asked Mar 04 '10 09:03

e-satis


People also ask

How does nose find tests?

nose, by default, follows a few simple rules for test discovery. If it looks like a test, it's a test. Names of directories, modules, classes and functions are compared against the testMatch regular expression, and those that match are considered tests. Any class that is a unittest.

What is nosetests python?

Nose is a popular test automation framework in Python that extends unittest to make testing easier. The other advantages of using the Nose framework are the enablement of auto discovery of test cases and documentation collection.


1 Answers

Try the --exe flag:

$ nosetests --help

...    

--exe               Look for tests in python modules that are executable.
                    Normal behavior is to exclude executable modules,
                    since they may not be import-safe [NOSE_INCLUDE_EXE]
like image 95
codeape Avatar answered Sep 20 '22 10:09

codeape