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

Function test_runner_with_stream

tests/test_testing.py:91–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90
91def test_runner_with_stream():
92 @click.command()
93 def test():
94 i = click.get_binary_stream("stdin")
95 o = click.get_binary_stream("stdout")
96 while True:
97 chunk = i.read(4096)
98 if not chunk:
99 break
100 o.write(chunk)
101 o.flush()
102
103 runner = CliRunner()
104 result = runner.invoke(test, input=BytesIO(b"Hello World!\n"))
105 assert not result.exception
106 assert result.output == "Hello World!\n"
107
108 runner = CliRunner(echo_stdin=True)
109 result = runner.invoke(test, input=BytesIO(b"Hello World!\n"))
110 assert not result.exception
111 assert result.output == "Hello World!\nHello World!\n"
112
113
114def test_prompts():

Callers

nothing calls this directly

Calls 2

invokeMethod · 0.95
CliRunnerClass · 0.90

Tested by

no test coverage detected