[英]run nosetests in all subdirectories
我可以使用nosetests
在workflow
文件夹中运行测试:
workflow maks$ nosetests
..........
----------------------------------------------------------------------
Ran 10 tests in 0.093s
OK
我的测试住在test
文件夹中:
workflow maks$ ls
__pycache__ iterations.py test
data iterationsClass.py testData
env iterationsClass.pyc
但是当我搬到父母目录时:
(py3env)Makss-Mac:workflow maks$ cd ..
它无法找到测试。
(py3env)Makss-Mac:Packages maks$ nosetests
----------------------------------------------------------------------
Ran 0 tests in 0.005s
OK
那么如何在所有子目录中进行nosetest搜索测试呢?
如果通过在其中放置__init__.py
使workflow
文件夹成为模块,则nose应该能够找到您的测试。
如果您不想将文件夹设置为模块,请将setup.cfg
放在要运行nosetests
的目录中,该tests
会自动将tests
选项传递给nosetests
以指定测试的相对位置。 像这样:
#setup.cfg contents:
[nosetests]
exe = True
tests = workflow/
您还可以使用相同的机制传递多个文件夹/测试:
#setup.cfg contents:
[nosetests]
exe = True
tests = workflow/, other/dir/full/of/tests/, direct/file/my_test.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.