def test_with_cmdline_and_configfile__prefers_cmdline(self, cli_runner_isolated):
assert ConfigFileProcessor1.config_files[0] == "hello.ini"
CONFIG_FILE_CONTENTS1 = """
[hello]
name = Alice
"""
write_configfile_with_contents("hello.ini", CONFIG_FILE_CONTENTS1)
assert os.path.exists("hello.ini")
assert not os.path.exists("hello.cfg")
CONTEXT_SETTINGS = dict(default_map=ConfigFileProcessor1.read_config())
@click.command(context_settings=CONTEXT_SETTINGS)
@click.option("-n", "--name", default="__CMDLINE__")
def hello(name):
click.echo("Hello %s" % name)
result = cli_runner_isolated.invoke(hello, ["--name", "CMDLINE_VALUE"])
assert result.output == "Hello CMDLINE_VALUE\n"
assert result.exit_code == 0
评论列表
文章目录