test_param.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:click-configfile 作者: click-contrib 项目源码 文件源码
def test_param_with_default__uses_cmdline_when_provided(self, cli_runner_isolated):
        assert ConfigFileProcessor1.config_files[0] == "hello.ini"
        CONFIG_FILE_CONTENTS = """
            [hello]
            name = Alice
            number = 43
            """
        write_configfile_with_contents("hello.ini", CONFIG_FILE_CONTENTS)
        assert os.path.exists("hello.ini")

        CONTEXT_SETTINGS = dict(default_map=ConfigFileProcessor1.read_config())
        @click.command(context_settings=CONTEXT_SETTINGS)
        @click.option("-n", "--name", type=str, default="__CMDLINE__")
        @click.option("--number", default=123)
        def hello_with_param_default2(name, number):
            click.echo("param: number= %s" % number)

        result = cli_runner_isolated.invoke(hello_with_param_default2,
                                            ["--number", "234"])
        assert result.output == "param: number= 234\n"
        assert result.exit_code == 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号