"Original" Linux system, execution nosetests Unable to traverse a directory or file beginning with "test" problem

Source: Internet
Author: User

A recent installation using nose in CentOS has found a problem: executing nosetests on the command line cannot traverse directories or files under the directory that begin with "test" and execute the tests in the file .

1 # nosetests-v23 ----------------------------------------------------------- -----------40in0. 000s56 OK

And under Windows It's possible:

1 nosetests-2 here...ok3test1.test4 ... ok45 ----------------------------------------------------------------------62 in 0 . 003s 7 8 OK
1#我执行nosetests-the directory of the v command below the file structure2#--test.py3#--test/4 # test1.py5 6 #test. PY7 def Test ():8     " " Here" "9Print'OK'Ten  One #test1. PY A def Test (): -Print'OK'
I execute the nosetests-v command directory below the file structure

Search on the internet for a long time, also did not find this is why and how to solve this problem, finally, a predecessor let me return to nose itself parameters to find, execution nosetests-h found the following two parameters:

1--exe look forTestsinchpython modules that is executable.2 Normal behavior is to exclude executable modules,3Since they may is not import-safe [Nose_include_exe]4--noexe Don't Look forTestsinchpython modules that is5 executable. (The default on the Windows platform are to6                          DoSo.)

The comment behind the--exe basically says: using this parameter, nose will go to the Python module to look for executable test cases, usually to include those executable modules, although they may not be safe to import ... and the note behind--noexe is exactly the opposite of the previous, In particular, the "Windows platform" makes me think that these two parameters may be the key to solve the problem, and then executed the following command:

1 [[email protected] test]# nosetests-v--exe2here... ok3test.test4 ... ok45 ----------------------------------------------------------------------6 2 inch 0 . 003s 7 8 OK

Sure enough, heart exultation! As for why nose to design this, I think:nose think that importing those files that can be executed by default may damage the system.

Because now the permissions for each file in my directory are this:

1 [email protected] test]# ll2Total dosage A3Drwxr-xr-x2Root root4096December to  at: -test14-rwxr--r--1Root root theJanuary6 Geneva: thetest.py5-rw-r--r--1Root root theJanuary6 Geneva: theTest.pyc

It can be seen that test.py has execute permission, and the execution permission can be executed properly by Chmod-x test.py.

1[Email protected] test]# nosetests-v2 3----------------------------------------------------------------------4Ran0Testsinch 0. 000s # No tests were run 5 6 OK7[Email protected] test]#chmod-x test.py # get rid of test.py execution permissions 8[Email protected] test]# nosetests-v9 Here ... okTen  One---------------------------------------------------------------------- ARan1Testinch 0. 001s # At this point, only test.py is running and not running test1.py because the test.py Execute permission is removed earlier  -  - OK the [email protected] test]# ll -Total dosage A -Drwxr-xr-x2Root root4096December to  at: -test1 --rw-r--r--1Root root theJanuary6 Geneva: thetest.py +-rw-r--r--1Root root theJanuary6 Geneva: theTest.pyc

So there are two ways to make nose traverse the test directory under Linux:

1, the use of--exe parameters, such as Nosetests-v--exe;

2, for all the test directory and file execution chmod-x.

"Original" Linux system, execution nosetests Unable to traverse a directory or file beginning with "test" problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.