这是 nosetests 只选择 none 可执行文件 .py 的正常行为吗?
Is this the normal behavior of nosetests to pick only none executable .py?
这是 nosetests 只选择 none 可执行文件的正常行为吗?
有没有其他方法可以设置 nosetests 以获取测试目录中的所有 .py?
项目的树结构:
├── __init__.py
├── lib
│ ├── add_quiz.py
│ ├── __init__.py
│ └── take_quiz.py
├── README
├── setup.py
└── tests
├── add_quiz_test.py
├── __init__.py
├── testCases
└── testData
将权限设置为不可执行,nosetests 正确拾取测试
[gliang@www quiz]$ chmod oug-x tests/add_quiz_test.py
[gliang@www quiz]$ nosetests -v -v -w .
nose.config: INFO: Set working dir to /home/gliang/work/prima/quiz
nose.config: INFO: Working directory /home/gliang/work/prima/quiz is a package; adding to sys.path
nose.selector: INFO: /home/gliang/work/prima/quiz/lib/add_quiz.py is executable; skipped
nose.selector: INFO: /home/gliang/work/prima/quiz/lib/take_quiz.py is executable; skipped
test1 (quiz.tests.add_quiz_test.add_quizTest) ... ok
test2 (quiz.tests.add_quiz_test.add_quizTest) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.001s
OK
当我将权限设置为可执行时不是
[gliang@www quiz]$ chmod oug+x tests/add_quiz_test.py
[gliang@www quiz]$ nosetests -v -v -w .
nose.config: INFO: Set working dir to /home/gliang/work/prima/quiz
nose.config: INFO: Working directory /home/gliang/work/prima/quiz is a package; adding to sys.path
nose.selector: INFO: /home/gliang/work/prima/quiz/lib/add_quiz.py is executable; skipped
nose.selector: INFO: /home/gliang/work/prima/quiz/lib/take_quiz.py is executable; skipped
nose.selector: INFO: /home/gliang/work/prima/quiz/tests/add_quiz_test.py is executable; skipped
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
This is expected, but there you can use the --exe
flag to collect tests from executable files:
It is important to note that the default behavior of nose is to not include tests from files which are executable. To include tests from such files, remove their executable bit or use the –exe flag (see ‘Options’ section below).
推理如下,来自同一页的下方:
Normal behavior is to exclude executable modules, since they may not be import-safe
这是 nosetests 只选择 none 可执行文件的正常行为吗? 有没有其他方法可以设置 nosetests 以获取测试目录中的所有 .py?
项目的树结构:
├── __init__.py
├── lib
│ ├── add_quiz.py
│ ├── __init__.py
│ └── take_quiz.py
├── README
├── setup.py
└── tests
├── add_quiz_test.py
├── __init__.py
├── testCases
└── testData
将权限设置为不可执行,nosetests 正确拾取测试
[gliang@www quiz]$ chmod oug-x tests/add_quiz_test.py
[gliang@www quiz]$ nosetests -v -v -w .
nose.config: INFO: Set working dir to /home/gliang/work/prima/quiz
nose.config: INFO: Working directory /home/gliang/work/prima/quiz is a package; adding to sys.path
nose.selector: INFO: /home/gliang/work/prima/quiz/lib/add_quiz.py is executable; skipped
nose.selector: INFO: /home/gliang/work/prima/quiz/lib/take_quiz.py is executable; skipped
test1 (quiz.tests.add_quiz_test.add_quizTest) ... ok
test2 (quiz.tests.add_quiz_test.add_quizTest) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.001s
OK
当我将权限设置为可执行时不是
[gliang@www quiz]$ chmod oug+x tests/add_quiz_test.py
[gliang@www quiz]$ nosetests -v -v -w .
nose.config: INFO: Set working dir to /home/gliang/work/prima/quiz
nose.config: INFO: Working directory /home/gliang/work/prima/quiz is a package; adding to sys.path
nose.selector: INFO: /home/gliang/work/prima/quiz/lib/add_quiz.py is executable; skipped
nose.selector: INFO: /home/gliang/work/prima/quiz/lib/take_quiz.py is executable; skipped
nose.selector: INFO: /home/gliang/work/prima/quiz/tests/add_quiz_test.py is executable; skipped
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
This is expected, but there you can use the --exe
flag to collect tests from executable files:
It is important to note that the default behavior of nose is to not include tests from files which are executable. To include tests from such files, remove their executable bit or use the –exe flag (see ‘Options’ section below).
推理如下,来自同一页的下方:
Normal behavior is to exclude executable modules, since they may not be import-safe