Run all Tests in Directory Using Nose

前端 未结 2 1092
情深已故
情深已故 2020-12-10 01:43

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

相关标签:
2条回答
  • 2020-12-10 01:55

    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.

    0 讨论(0)
  • 2020-12-10 02:04

    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
    
    0 讨论(0)
提交回复
热议问题