Skip to content
Myr

Ignore broken PAGER values

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

Fix #403

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parent dbd4069 · Browse files · 3 files+11 added−5 removed
This commit

State

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

Diff stats

3 files+11 added−5 removed

  • tests:+5 added−2 removed
  • other:+6 added−3 removed

3 files+11 added−5 removed

modified:click/_termui_impl.py+4 added-3 removed
255 unmodified lines
256 """Decide what method to use for paging through text."""257 stdout = _default_text_stdout()258 if not isatty(sys.stdin) or not isatty(stdout):259 return _nullpager(stdout, text, color)260 if 'PAGER' in os.environ:260 pager_cmd = (os.environ.get('PAGER', None) or '').strip()261 if pager_cmd:262 if WIN:262 return _tempfilepager(text, os.environ['PAGER'], color)263 return _pipepager(text, os.environ['PAGER'], color)263 return _tempfilepager(text, pager_cmd, color)264 return _pipepager(text, pager_cmd, color)265 if os.environ.get('TERM') in ('dumb', 'emacs'):266 return _nullpager(stdout, text, color)267 if WIN or sys.platform.startswith('os2'):268 return _tempfilepager(text, 'more <', color)
260 unmodified lines
modified:tests/test_utils.py+5 added-2 removed
1import os2import sys34import pytest56import click7import click.utils8import click._termui_impl9
130 unmodified lines
140 out, err = capsys.readouterr()141 assert out == 'Password: \nScrew you.\n'142143144@pytest.mark.parametrize('cat', ['cat', 'cat ', 'cat '])142def test_echo_via_pager(monkeypatch, capfd):143 monkeypatch.setitem(os.environ, 'PAGER', 'cat')145def test_echo_via_pager(monkeypatch, capfd, cat):146 monkeypatch.setitem(os.environ, 'PAGER', cat)147 monkeypatch.setattr(click._termui_impl, 'isatty', lambda x: True)148 click.echo_via_pager('haha')149 out, err = capfd.readouterr()150 assert out == 'haha\n'
125 unmodified lines
modified:CHANGES+2 added
20 unmodified lines
21- The `echo` function is now threadsafe: It calls the `write` method of the22 underlying object only once.23- `prompt(hide_input=True)` now prints a newline on `^C`.24- Click will now warn if users are using ``unicode_literals``.25- Click will now ignore the ``PAGER`` environment variable if it is empty or26 contains only whitespace.2728Version 4.129-----------30
221 unmodified lines