无法在nosetests中使用nose-testconfig 0.6插件传递多个覆盖参数

发布于 2024-09-02 10:59:39 字数 1059 浏览 4 评论 0原文

只有当我在命令行上传递覆盖参数,例如,

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

如果有人有任何线索,请告诉我。

I am able to override multiple config parameters using the nose-testconfig plugin only if I pass the overriding parameters on the command line, e.g.

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

But when I define the same thing inside nose.cfg, than only the value for the last parameter is modified. e.g.

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

I checked the plugin code. It looks fine to me. Here is part of the plugin code:

    parser.add_option(

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

configure:

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

Let me know if any one has any clue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔嚣张 2024-09-09 10:59:39

请在下面找到我的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 值有效(即最后一个值)。但是当我在命令行上指定相同的值时,这两个值都有效

Please find my nose.cfg file below:

[nosetests]
verbosity=2

tc-file = setup_config.py

tc-format = python

all-modules = True

tc = server2.env2:abc

tc = jack.env1:asl

and my config file looks like:

[server2]

env2=server2

[jack]

env1=server1

In the above example only jack.env1:as1 value is effective (i.e last value). But when I specify the same on command line than both values are effective

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文