import click def test_echo(runner): with runner.isolation() as out: click.echo(u'\N{SNOWMAN}') click.echo(b'\x44\x44') click.echo(42, nl=False) click.echo(b'a', nl=False) bytes = out.getvalue() assert bytes == b'\xe2\x98\x83\nDD\n42a'