def test_runner_with_stream(): def test(): i = termui.get_binary_stream('stdin') o = termui.get_binary_stream('stdout') while 1: chunk = i.read(4096) if not chunk: break o.write(chunk) o.flush() runner = CliRunner() result = runner.invoke(test, input=ReasonableBytesIO(b'Hello World!\n')) assert not result.exception assert result.output == 'Hello World!\n' runner = CliRunner(echo_stdin=True) result = runner.invoke(test, input=ReasonableBytesIO(b'Hello World!\n')) assert not result.exception assert result.output == 'Hello World!\nHello World!\n'
def test_runner_with_stream(): @click.command() def test(): i = click.get_binary_stream("stdin") o = click.get_binary_stream("stdout") while 1: chunk = i.read(4096) if not chunk: break o.write(chunk) o.flush() runner = CliRunner() result = runner.invoke(test, input=ReasonableBytesIO(b"Hello World!\n")) assert not result.exception assert result.output == "Hello World!\n" runner = CliRunner(echo_stdin=True) result = runner.invoke(test, input=ReasonableBytesIO(b"Hello World!\n")) assert not result.exception assert result.output == "Hello World!\nHello World!\n"