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

Function test_echo

tests/test_utils.py:71–92  ·  view source on GitHub ↗
(runner)

Source from the content-addressed store, hash-verified

69
70
71def 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
95def test_echo_custom_file():

Callers

nothing calls this directly

Calls 3

isolationMethod · 0.80
getvalueMethod · 0.80
invokeMethod · 0.45

Tested by

no test coverage detected