| 69 | |
| 70 | |
| 71 | def test_echo(runner): |
| 72 | with runner.isolation() as outstreams: |
| 73 | click.echo("\N{SNOWMAN}") |
| 74 | click.echo(b"\x44\x44") |
| 75 | click.echo(42, nl=False) |
| 76 | click.echo(b"a", nl=False) |
| 77 | click.echo("\x1b[31mx\x1b[39m", nl=False) |
| 78 | bytes = outstreams[0].getvalue().replace(b"\r\n", b"\n") |
| 79 | assert bytes == b"\xe2\x98\x83\nDD\n42ax" |
| 80 | |
| 81 | # if wrapped, we expect bytes to survive. |
| 82 | @click.command() |
| 83 | def cli(): |
| 84 | click.echo(b"\xf6") |
| 85 | |
| 86 | result = runner.invoke(cli, []) |
| 87 | assert result.stdout_bytes == b"\xf6\n" |
| 88 | |
| 89 | # Ensure we do not strip for bytes. |
| 90 | with runner.isolation() as outstreams: |
| 91 | click.echo(bytearray(b"\x1b[31mx\x1b[39m"), nl=False) |
| 92 | assert outstreams[0].getvalue() == b"\x1b[31mx\x1b[39m" |
| 93 | |
| 94 | |
| 95 | def test_echo_custom_file(): |