2013-07-26 49 views
1

从这使用鼻子,我怎么检索已通过命令行配置文件列表运行测试的代码获取的使用的配置文件列表(不解析ARGS自己因为鼻子应该公开这些值地方),如,从鼻子

nosetests -c default.ini -c staging.ini 

那么这将导致,

[default.ini, staging.ini] 

我似乎无法找到nose.config对象上的这些值。

+1

您是否尝试过'nose.config.user_config_files()'或'nose.config.all_config_files()'? –

+0

我有,他们都空着。 – sowa

回答

1

好像你的问题是,你命名你的配置文件不同的比默认的鼻子配置文件应该被命名。

从nose.config

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)) 


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 

短的这是,那个鼻子寻找一个名为〜/ .noserc或〜/ nose.cfg默认的配置文件。如果他们不叫这样的鼻子不会接他们,你将不得不手动指定配置文件的名称,就像你在命令行上做现在

说比如你有一些对象配置这是nose.config.Config实例然后让你的配置文件名最好的办法是说

>>> from nose.config import Config 
>>> c = Config() 
>>> c.configure(argv=["nosetests", "-c", "foo.txt"]) 
>>> c.options.files 
['foo.txt']