Skip to content
Myr

Fixed a regression for echo_via_pager on 3.x. This fixes #185

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 47f5663 · Browse files · 2 files+16 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−3 removed

  • tests:+11 added−0 removed
  • other:+5 added−3 removed

2 files+16 added−3 removed

modified:click/_termui_impl.py+5 added-3 removed
296 unmodified lines
297 text = strip_ansi(text)298299 c = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,300 env=env)301 encoding = get_best_encoding(c.stdin)302 try:302 c.stdin.write(text)303 c.stdin.write(text.encode(encoding, 'replace'))304 c.stdin.close()305 except IOError:306 pass307 c.wait()
4 unmodified lines
312 import tempfile313 filename = tempfile.mktemp()314 if not color:315 text = strip_ansi(text)316 encoding = get_best_encoding(sys.stdout)315 with open_stream(filename, 'w')[0] as f:316 f.write(text)317 with open_stream(filename, 'wb')[0] as f:318 f.write(text.encode(encoding))319 try:320 os.system(cmd + ' "' + filename + '"')321 finally:322 os.unlink(filename)
186 unmodified lines
modified:tests/test_utils.py+11 added
1import os2import sys3import click45import click._termui_impl678def test_echo(runner):9 with runner.isolation() as out:10 click.echo(u'\N{SNOWMAN}')11 click.echo(b'\x44\x44')
101 unmodified lines
113114 result = runner.invoke(test_no, input='n\n')115 assert not result.exception116 assert result.output == 'Foo [Y/n]: n\nno :(\n'117118119def test_echo_via_pager(monkeypatch, capfd):120 monkeypatch.setitem(os.environ, 'PAGER', 'cat')121 monkeypatch.setattr(click._termui_impl, 'isatty', lambda x: True)122 click.echo_via_pager('haha')123 out, err = capfd.readouterr()124 assert out == 'haha\n'