我有以下目录结构:
main/
|setup.cfg
|foo.cfg
|tests/
|setup.cfg
|foo.cfg
|test_simple.py
并测试test_simple.py
:
from nose.tools import *
from nose.config import all_config_files, user_config_files
def test_singe():
print 'all:', all_config_files()
print 'user:', user_config_files()
assert_true(False)
从main/
我运行nosetests tests/test_simple.py
,我得到:
all: ['setup.cfg']
user: []
我认为all_config_files
或user_config_files
将返回所有配置文件。但我只得到最高setup.cfg
。
根据docs:
all_config_files()
Return path to any existing user config files, plus any setup.cfg
in the current working directory.
user_config_files()
Return path to any existing user config files
我希望找到文件main/tests/*.cfg
。有什么问题?
答案 0 :(得分:1)
根据source code,user_config_files
将只返回用户主文件夹中的配置:
config_files = [
# Linux users will prefer this
"~/.noserc",
# Windows users will prefer this
"~/nose.cfg"
]
...
def user_config_files():
"""Return path to any existing user config files
"""
return filter(os.path.exists,
map(os.path.expanduser, config_files))
all_config_files
将从根目录(运行nosetests的地方)返回user_config_files
+ setup.cfg:
def all_config_files():
"""Return path to any existing user config files, plus any setup.cfg
in the current working directory.
"""
user = user_config_files()
if os.path.exists('setup.cfg'):
return user + ['setup.cfg']
return user
希望有所帮助。