def test_with_configfile12__prefers_configfile1(self, cli_runner_isolated):
assert ConfigFileProcessor1.config_files == ["hello.ini", "hello.cfg"]
CONFIG_FILE_CONTENTS1 = """
[hello]
name = alice
"""
CONFIG_FILE_CONTENTS2 = """
[hello]
name = bob
"""
write_configfile_with_contents("hello.ini", CONFIG_FILE_CONTENTS1)
write_configfile_with_contents("hello.cfg", CONFIG_FILE_CONTENTS2)
assert os.path.exists("hello.ini")
assert 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)
assert result.output == "Hello alice\n"
assert result.exit_code == 0
评论列表
文章目录