1

只有当我在命令行上传递覆盖参数时,我才能使用nose-testconfig插件覆盖多个配置参数,例如

nosetests -c nose.cfg -s --tc=jack.env1:asl --tc=server2.env2:abc

但是当我在里面定义相同的东西时nose.cfg,只修改了最后一个参数的值。例如

tc = server2.env2:abc
tc = jack.env1:asl

我检查了插件代码。我觉得很好。这是插件代码的一部分:

    parser.add_option(

        "--tc", action="append", 
        dest="overrides",
        default = [],
        help="Option:Value specific overrides.")

配置:

    if options.overrides:
        self.overrides = []
        overrides = tolist(options.overrides)
        for override in overrides:
            keys, val = override.split(":")
            if options.exact:
                config[keys] = val
            else:                    
                ns = ''.join(['["%s"]' % i for i in keys.split(".") ])
                # BUG: Breaks if the config value you're overriding is not
                # defined in the configuration file already. TBD
                exec('config%s = "%s"' % (ns, val))

让我知道是否有人有任何线索。

4

1 回答 1

0

请在下面找到我的 nose.cfg 文件:

[nosetests]
verbosity=2

tc-file = setup_config.py

tc-format = python

all-modules = True

tc = server2.env2:abc

tc = jack.env1:asl

我的配置文件看起来像:

[server2]

env2=server2

[jack]

env1=server1

在上面的示例中,只有 jack.env1:as1 值有效(即最后一个值)。但是当我在命令行上指定相同的值时,两个值都有效

于 2010-05-24T18:04:57.463 回答