Run all Tests in Directory Using Nose

天大地大妈咪最大 提交于 2019-11-28 09:40:33

From Python Testing: Beginner's Guide by Daniel Arbuckle:

Nose looks for tests in directories and modules whose names start with test and Test, or contain a '_', '.', or '-' followed by test or Test. 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

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!