MCPcopy
hub / github.com/pallets/click / test_echo_stdin_prompts

Function test_echo_stdin_prompts

tests/test_testing.py:51–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49
50
51def test_echo_stdin_prompts():
52 @click.command()
53 def test_python_input():
54 foo = input("Foo: ")
55 click.echo(f"foo={foo}")
56
57 runner = CliRunner(echo_stdin=True)
58 result = runner.invoke(test_python_input, input="bar bar\n")
59 assert not result.exception
60 assert result.output == "Foo: bar bar\nfoo=bar bar\n"
61
62 @click.command()
63 @click.option("--foo", prompt=True)
64 def test_prompt(foo):
65 click.echo(f"foo={foo}")
66
67 result = runner.invoke(test_prompt, input="bar bar\n")
68 assert not result.exception
69 assert result.output == "Foo: bar bar\nfoo=bar bar\n"
70
71 @click.command()
72 @click.option("--foo", prompt=True, hide_input=True)
73 def test_hidden_prompt(foo):
74 click.echo(f"foo={foo}")
75
76 result = runner.invoke(test_hidden_prompt, input="bar bar\n")
77 assert not result.exception
78 assert result.output == "Foo: \nfoo=bar bar\n"
79
80 @click.command()
81 @click.option("--foo", prompt=True)
82 @click.option("--bar", prompt=True)
83 def test_multiple_prompts(foo, bar):
84 click.echo(f"foo={foo}, bar={bar}")
85
86 result = runner.invoke(test_multiple_prompts, input="one\ntwo\n")
87 assert not result.exception
88 assert result.output == "Foo: one\nBar: two\nfoo=one, bar=two\n"
89
90
91def test_runner_with_stream():

Callers

nothing calls this directly

Calls 2

invokeMethod · 0.95
CliRunnerClass · 0.90

Tested by

no test coverage detected