| 89 | |
| 90 | |
| 91 | def 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 | |
| 114 | def test_prompts(): |