From a25e60a73561ca89d1f7d3b4e684b6dee112fb8a Mon Sep 17 00:00:00 2001 From: Todd Leonhardt <2812720+tleonhardt@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:29:52 -0500 Subject: [PATCH 1/5] Print ppaged() output when the pager program cannot be run ppaged() hands its output to the shell command in `pager` or `pager_chop` and prints nothing itself. Where that program is not installed the shell reports it and exits, and the output is lost: in a stock Debian slim container, which ships no `less`, a command such as `help -v` shows only "/bin/sh: 1: less: not found". Print the output when the shell could not run the pager at all. A POSIX shell says so with status 127, or 126 for a program it cannot execute. cmd.exe exits with 1, which a pager may also do for reasons of its own, so there the program is looked for as well. A pager which did run has had the output, whatever status it exits with, and nothing is printed again. --- CHANGELOG.md | 3 ++ cmd2/cmd2.py | 39 +++++++++++++++++++-- docs/features/os.md | 4 +++ tests/test_cmd2.py | 83 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84cf989e2..34a43c6cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ - Bug Fixes - Fixed file path completion for names containing square brackets, including bracketed working directories and home directories. + - `ppaged()` now prints its output when the configured pager program cannot be run, for example + where `less` is not installed. Previously only the shell's error was shown and the output was + lost. ## 4.4.2 (November 11, 2026) diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 4107fbfc6..e7cc0a8e7 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1926,6 +1926,31 @@ def pfeedback( rich_print_kwargs=rich_print_kwargs, ) + @staticmethod + def _pager_failed_to_start(command: str, returncode: int) -> bool: + """Return whether the shell could not run a pager at all, so that it showed nothing. + + A pager which did run has had the output, whatever status it exited with. + + :param command: the pager command given to the shell + :param returncode: the status the shell exited with + """ + if returncode == 0: + return False + if sys.platform.startswith("win"): + # cmd.exe exits with 1 for a command it cannot find, which a pager may also do for + # reasons of its own. Tell them apart by whether there is such a program. + import shlex + import shutil + + try: + words = shlex.split(command, posix=False) + except ValueError: + return False + return bool(words) and shutil.which(words[0].strip('"')) is None + # What a POSIX shell exits with for a command it cannot find, or cannot execute. + return returncode in (126, 127) + def ppaged( self, *objects: Any, @@ -1947,6 +1972,9 @@ def ppaged( fits on the screen. A pager is not used inside a script (Python or text) or when output is redirected or piped, and in these cases, output is sent to `poutput`. + If the pager program cannot be run, for example because it is not installed, the output + is printed without one. + :param chop: True -> causes lines longer than the screen width to be chopped (truncated) rather than wrapped - truncated text is still accessible by scrolling with the right & left arrow keys - chopping is ideal for displaying wide tabular data as is done in utilities like pgcli @@ -1995,8 +2023,10 @@ def ppaged( soft_wrap=soft_wrap, **(rich_print_kwargs if rich_print_kwargs is not None else {}), ) + output = capture.get() # As for a pipe: the pager gets UTF-8, and on Windows the console is UTF-8 while it runs. - output_bytes = capture.get().encode("utf-8", "replace") + output_bytes = output.encode("utf-8", "replace") + pager = self.pager_chop if chop else self.pager # Prevent KeyboardInterrupts while in the pager. The pager application will # still receive the SIGINT since it is in the same process group as us. @@ -2004,7 +2034,7 @@ def ppaged( import subprocess pipe_proc = subprocess.Popen( # noqa: S602 - self.pager_chop if chop else self.pager, + pager, shell=True, stdin=subprocess.PIPE, stdout=self.stdout, @@ -2029,6 +2059,11 @@ def ppaged( except (OSError, termios.error): pass + if self._pager_failed_to_start(pager, pipe_proc.returncode): + # The shell has said why. Nothing was shown, and only the pager was going to. + self.stdout.write(output) + self.stdout.flush() + else: self.poutput( *objects, diff --git a/docs/features/os.md b/docs/features/os.md index 444822fd6..ef36dcbc1 100644 --- a/docs/features/os.md +++ b/docs/features/os.md @@ -44,6 +44,10 @@ system. Output of any command can be displayed one page at a time using the [cmd2.Cmd.ppaged][] method. +The pager is the command in `self.pager`, or `self.pager_chop` when chopping long lines: `less` on +POSIX systems and `more` on Windows by default. If that program cannot be run, for example because +it is not installed, the output is printed without paging. + Alternatively, a terminal pager can be invoked directly using the ability to run shell commands with the `!` shortcut like so: diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 01efe8de7..f803db89a 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -4010,6 +4010,89 @@ def utf8_console(): assert events == ["utf-8 console", "pager started", "pager exited", "restored"] +class FakeTerminal(io.TextIOWrapper): + """A real file which says it is a terminal, so that a pager's shell can be given it to write to.""" + + def isatty(self) -> bool: + return True + + +@pytest.fixture +def paging_app(outsim_app, monkeypatch, tmp_path): + """An application which will page, and whatever reaches its terminal.""" + stdin_mock = mock.MagicMock() + stdin_mock.isatty.return_value = True + monkeypatch.setattr(outsim_app, "stdin", stdin_mock) + if not sys.platform.startswith("win") and os.environ.get("TERM") is None: + monkeypatch.setenv("TERM", "simulated") + with FakeTerminal((tmp_path / "terminal").open("w+b"), encoding="utf-8") as terminal: + monkeypatch.setattr(outsim_app, "stdout", terminal) + + def shown() -> str: + terminal.flush() + terminal.seek(0) + return terminal.read() + + yield outsim_app, shown + + +@pytest.mark.parametrize("chop", [True, False]) +def test_ppaged_shows_the_output_when_the_pager_cannot_be_run(paging_app, capfd, chop) -> None: + """A pager which is not installed must not cost the user the output. + + The shell reports the missing program and exits. Nothing has been shown by then, and + without the pager there is nobody else to show it. + """ + app, shown = paging_app + app.pager = app.pager_chop = "cmd2-no-such-pager-program --some-option" + + app.ppaged("first line\nsecond line", chop=chop) + + assert shown() == "first line\nsecond line\n" + # The shell said why there was no pager. + assert "cmd2-no-such-pager-program" in capfd.readouterr().err + + +def test_ppaged_does_not_repeat_output_after_a_pager_which_ran_and_failed(paging_app) -> None: + """Only a pager which could not be started is made up for: one which ran has had the output.""" + app, shown = paging_app + app.pager = f'"{sys.executable}" -c "import sys; sys.stdin.read(); sys.exit(1)"' + + app.ppaged("first line\nsecond line") + + assert shown() == "" + + +@pytest.mark.parametrize( + ("platform", "command", "returncode", "found", "expected"), + [ + pytest.param("linux", "less -RXF", 127, True, True, id="a POSIX shell found no such command"), + pytest.param("linux", "less -RXF", 126, True, True, id="a POSIX shell could not execute it"), + pytest.param("linux", "less -RXF", 1, False, False, id="a POSIX pager failed by itself"), + pytest.param("linux", "less -RXF", 0, False, False, id="a POSIX pager succeeded"), + pytest.param("win32", "less -RXF", 1, False, True, id="cmd.exe found no such command"), + pytest.param("win32", '"C:\\Program Files\\less.exe" -R', 1, False, True, id="cmd.exe found no such quoted path"), + pytest.param("win32", "more", 1, True, False, id="a Windows pager failed by itself"), + pytest.param("win32", "less -RXF", 0, False, False, id="a Windows pager succeeded"), + pytest.param("win32", 'less "unbalanced', 1, False, False, id="a Windows command which cannot be taken apart"), + pytest.param("win32", "", 1, False, False, id="no Windows command at all"), + ], +) +def test_pager_failed_to_start(monkeypatch, platform, command, returncode, found, expected) -> None: + looked_for = [] + + def which(program: str) -> str | None: + looked_for.append(program) + return program if found else None + + monkeypatch.setattr(sys, "platform", platform) + monkeypatch.setattr("shutil.which", which) + + assert cmd2.Cmd._pager_failed_to_start(command, returncode) is expected + # A quoted program is looked for by its name, not with its quotes. + assert all(not program.startswith('"') for program in looked_for) + + def test_ppaged_no_pager(outsim_app) -> None: """Since we're not in a fully-functional terminal, ppaged() will just call poutput().""" msg = "testing..." From 04ff8eff2c0e802abb4fc80c202ba7b0704a2cbf Mon Sep 17 00:00:00 2001 From: Todd Leonhardt <2812720+tleonhardt@users.noreply.github.com> Date: Sun, 15 Nov 2026 13:39:32 -0500 Subject: [PATCH 2/5] Fall through to poutput() when the pager cannot be run ppaged() had two ways of printing without a pager: poutput() where it would not page at all, and a write of the text captured for the pager where the pager could not be started. Return early once a pager has run, and let both cases reach the one poutput() call. Chopping turns soft wrap on so that a pager can scroll sideways. That was done by overwriting the caller's soft_wrap, so it is now kept apart and used only for what the pager is given. Without a pager there is nothing to scroll, and the output is wrapped as the caller asked, as the docstring already said. --- cmd2/cmd2.py | 40 +++++++++++++++++++--------------------- tests/test_cmd2.py | 10 ++++++++++ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index e7cc0a8e7..d2f5d84ae 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2002,9 +2002,8 @@ def ppaged( # Check if we are outputting to a pager. if functional_terminal and can_block: - # Chopping overrides soft_wrap - if chop: - soft_wrap = True + # Chopping overrides soft_wrap, but only for what the pager is given + pager_soft_wrap = soft_wrap or chop # Generate the bytes to send to the pager console = self._get_core_print_console( @@ -2020,7 +2019,7 @@ def ppaged( end=end, style=style, justify=justify, - soft_wrap=soft_wrap, + soft_wrap=pager_soft_wrap, **(rich_print_kwargs if rich_print_kwargs is not None else {}), ) output = capture.get() @@ -2059,24 +2058,23 @@ def ppaged( except (OSError, termios.error): pass - if self._pager_failed_to_start(pager, pipe_proc.returncode): - # The shell has said why. Nothing was shown, and only the pager was going to. - self.stdout.write(output) - self.stdout.flush() + if not self._pager_failed_to_start(pager, pipe_proc.returncode): + return - else: - self.poutput( - *objects, - sep=sep, - end=end, - style=style, - soft_wrap=soft_wrap, - justify=justify, - emoji=emoji, - markup=markup, - highlight=highlight, - rich_print_kwargs=rich_print_kwargs, - ) + # The shell has said why. Nothing was shown, and only the pager was going to, so print without one. + + self.poutput( + *objects, + sep=sep, + end=end, + style=style, + soft_wrap=soft_wrap, + justify=justify, + emoji=emoji, + markup=markup, + highlight=highlight, + rich_print_kwargs=rich_print_kwargs, + ) def ppretty( self, diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index f803db89a..f5da1b29a 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -4053,6 +4053,16 @@ def test_ppaged_shows_the_output_when_the_pager_cannot_be_run(paging_app, capfd, assert "cmd2-no-such-pager-program" in capfd.readouterr().err +def test_ppaged_without_a_pager_wraps_as_the_caller_asked(paging_app) -> None: + """Chopping turns soft wrap on for a pager to scroll sideways. With no pager, the caller's choice stands.""" + app, shown = paging_app + app.pager_chop = "cmd2-no-such-pager-program" + + app.ppaged("word " * 400, chop=True, soft_wrap=False) + + assert len(shown().splitlines()) > 1 + + def test_ppaged_does_not_repeat_output_after_a_pager_which_ran_and_failed(paging_app) -> None: """Only a pager which could not be started is made up for: one which ran has had the output.""" app, shown = paging_app From 22654c46bc516441574bd8025e0921122e28e845 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt <2812720+tleonhardt@users.noreply.github.com> Date: Sun, 15 Nov 2026 13:45:24 -0500 Subject: [PATCH 3/5] Fix indentation and improve wording of comment --- cmd2/cmd2.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index d2f5d84ae..93bf741ee 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2061,8 +2061,7 @@ def ppaged( if not self._pager_failed_to_start(pager, pipe_proc.returncode): return - # The shell has said why. Nothing was shown, and only the pager was going to, so print without one. - + # For some reason we are unable to start the pager, so print without one. self.poutput( *objects, sep=sep, From 21addc8bee63902d3a28346ab9428e3117c37821 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt <2812720+tleonhardt@users.noreply.github.com> Date: Sun, 15 Nov 2026 14:03:34 -0500 Subject: [PATCH 4/5] Try a pager which cannot be run only once, and render for it once Where the pager program is not installed, every ppaged() call started a shell which failed, so the shell's error was shown before the output each time, and the output was rendered twice. Remember a pager command which the shell could not run and print without it from then on. Another command set in `pager` or `pager_chop` is still tried. The first time, the objects had been rendered for the pager and were then rendered again by poutput(). One which can only be rendered once came out empty the second time, and the output was still lost. Write the text rendered for the pager instead. Only where chopping changed the wrapping from what the caller asked for is it rendered again. The comment above the poutput() call spoke of a pager which could not be started, but that call is also where output goes when no pager is tried. --- CHANGELOG.md | 3 ++- cmd2/cmd2.py | 26 +++++++++++++++++++----- docs/features/os.md | 3 ++- tests/test_cmd2.py | 49 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34a43c6cf..d3f834fb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ directories and home directories. - `ppaged()` now prints its output when the configured pager program cannot be run, for example where `less` is not installed. Previously only the shell's error was shown and the output was - lost. + lost. A pager command which could not be run is not tried again while the application is + running, so the shell's error is shown only once. ## 4.4.2 (November 11, 2026) diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 93bf741ee..5780b68cb 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -668,6 +668,9 @@ def __init__( self.pager = "less -RXF" self.pager_chop = "less -SRXF" + # Pager commands which the shell could not run. Each is tried, and reported by the shell, only once. + self._unrunnable_pagers: set[str] = set() + # This boolean flag stores whether cmd2 will allow clipboard related features self.allow_clipboard = allow_clipboard @@ -1973,7 +1976,7 @@ def ppaged( redirected or piped, and in these cases, output is sent to `poutput`. If the pager program cannot be run, for example because it is not installed, the output - is printed without one. + is printed without one. That pager command is not tried again while the application runs. :param chop: True -> causes lines longer than the screen width to be chopped (truncated) rather than wrapped - truncated text is still accessible by scrolling with the right & left arrow keys @@ -2000,8 +2003,10 @@ def ppaged( # A pager application blocks, so only run one if not redirecting or running a script (either text or Python). can_block = not (self._redirecting or self.in_pyscript() or self.in_script()) - # Check if we are outputting to a pager. - if functional_terminal and can_block: + pager = self.pager_chop if chop else self.pager + + # Check if we are outputting to a pager. One which the shell could not run is not tried again. + if functional_terminal and can_block and pager not in self._unrunnable_pagers: # Chopping overrides soft_wrap, but only for what the pager is given pager_soft_wrap = soft_wrap or chop @@ -2025,7 +2030,6 @@ def ppaged( output = capture.get() # As for a pipe: the pager gets UTF-8, and on Windows the console is UTF-8 while it runs. output_bytes = output.encode("utf-8", "replace") - pager = self.pager_chop if chop else self.pager # Prevent KeyboardInterrupts while in the pager. The pager application will # still receive the SIGINT since it is in the same process group as us. @@ -2061,7 +2065,19 @@ def ppaged( if not self._pager_failed_to_start(pager, pipe_proc.returncode): return - # For some reason we are unable to start the pager, so print without one. + # The shell has said why there is no pager. Remember that, so it is not asked every time. + self._unrunnable_pagers.add(pager) + + if pager_soft_wrap == soft_wrap: + # What was rendered for the pager is what poutput() would print. Write that instead + # of rendering the objects a second time, which not all of them can be. + self.stdout.write(output) + self.stdout.flush() + return + + # Chopping changed the wrapping for the pager, so render again as the caller asked. + + # Nothing is paging the output, so print it. self.poutput( *objects, sep=sep, diff --git a/docs/features/os.md b/docs/features/os.md index ef36dcbc1..805fcac50 100644 --- a/docs/features/os.md +++ b/docs/features/os.md @@ -46,7 +46,8 @@ Output of any command can be displayed one page at a time using the [cmd2.Cmd.pp The pager is the command in `self.pager`, or `self.pager_chop` when chopping long lines: `less` on POSIX systems and `more` on Windows by default. If that program cannot be run, for example because -it is not installed, the output is printed without paging. +it is not installed, the output is printed without paging. A pager command which could not be run is +not tried again while the application is running, so the shell reports it only once. Alternatively, a terminal pager can be invoked directly using the ability to run shell commands with the `!` shortcut like so: diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index f5da1b29a..7091d67a4 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -4073,6 +4073,55 @@ def test_ppaged_does_not_repeat_output_after_a_pager_which_ran_and_failed(paging assert shown() == "" +class RendersOnce: + """A renderable which only has its lines to give the first time it is rendered.""" + + def __init__(self, *lines: str) -> None: + self._lines = iter(lines) + + def __rich_console__(self, console, options): + yield from self._lines + + +@pytest.mark.parametrize("chop", [True, False]) +def test_ppaged_renders_once_when_the_pager_cannot_be_run(paging_app, chop) -> None: + """What was rendered for the pager is what gets shown: not everything can be rendered a second time.""" + app, shown = paging_app + app.pager = app.pager_chop = "cmd2-no-such-pager-program" + + app.ppaged(RendersOnce("first line", "second line"), chop=chop) + + assert shown() == "first line\nsecond line\n" + + +def test_ppaged_does_not_try_again_a_pager_which_cannot_be_run(paging_app, capfd) -> None: + """The shell says once that there is no such pager, not every time something is paged.""" + app, shown = paging_app + app.pager = "cmd2-no-such-pager-program" + + app.ppaged("first") + assert "cmd2-no-such-pager-program" in capfd.readouterr().err + + with mock.patch("subprocess.Popen") as popen_mock: + app.ppaged(RendersOnce("second")) + + popen_mock.assert_not_called() + assert capfd.readouterr().err == "" + assert shown() == "first\nsecond\n" + + +def test_ppaged_tries_another_pager_after_one_which_cannot_be_run(paging_app) -> None: + """Only the command which could not be run is given up on, so setting a pager which works is enough.""" + app, shown = paging_app + app.pager = "cmd2-no-such-pager-program" + app.ppaged("unpaged") + + app.pager = f'"{sys.executable}" -c "import sys; sys.stdout.write(sys.stdin.read().upper())"' + app.ppaged("paged") + + assert shown() == "unpaged\nPAGED\n" + + @pytest.mark.parametrize( ("platform", "command", "returncode", "found", "expected"), [ From 8705d13866339d7abbe5702be75853bd821f3ddf Mon Sep 17 00:00:00 2001 From: Todd Leonhardt <2812720+tleonhardt@users.noreply.github.com> Date: Sun, 15 Nov 2026 14:19:56 -0500 Subject: [PATCH 5/5] Print through poutput() alone when the pager cannot be run The first time a pager could not be run, the text rendered for it was written straight to stdout, so that the objects were not rendered twice. That went around poutput(), unlike every later call and the rest of cmd2, so an application which overrides poutput() or print_to() did not see it. Fall through to the one poutput() call there too. The objects are rendered a second time that once, and not again, since the pager is not retried. `pager` and `pager_chop` are separate commands and each is tried once, so the shell's error may be shown once for each. Say that in the changelog and the documentation, instead of that it is shown only once. --- CHANGELOG.md | 2 +- cmd2/cmd2.py | 13 ++----------- docs/features/os.md | 3 ++- tests/test_cmd2.py | 16 ++++------------ 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3f834fb0..6a5421f11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - `ppaged()` now prints its output when the configured pager program cannot be run, for example where `less` is not installed. Previously only the shell's error was shown and the output was lost. A pager command which could not be run is not tried again while the application is - running, so the shell's error is shown only once. + running, so the shell's error is shown once for each pager command instead of every time. ## 4.4.2 (November 11, 2026) diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 5780b68cb..a79c8de15 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2027,9 +2027,8 @@ def ppaged( soft_wrap=pager_soft_wrap, **(rich_print_kwargs if rich_print_kwargs is not None else {}), ) - output = capture.get() # As for a pipe: the pager gets UTF-8, and on Windows the console is UTF-8 while it runs. - output_bytes = output.encode("utf-8", "replace") + output_bytes = capture.get().encode("utf-8", "replace") # Prevent KeyboardInterrupts while in the pager. The pager application will # still receive the SIGINT since it is in the same process group as us. @@ -2066,17 +2065,9 @@ def ppaged( return # The shell has said why there is no pager. Remember that, so it is not asked every time. + # Nothing has been shown, so this once the objects are rendered a second time below. self._unrunnable_pagers.add(pager) - if pager_soft_wrap == soft_wrap: - # What was rendered for the pager is what poutput() would print. Write that instead - # of rendering the objects a second time, which not all of them can be. - self.stdout.write(output) - self.stdout.flush() - return - - # Chopping changed the wrapping for the pager, so render again as the caller asked. - # Nothing is paging the output, so print it. self.poutput( *objects, diff --git a/docs/features/os.md b/docs/features/os.md index 805fcac50..7d6489bc4 100644 --- a/docs/features/os.md +++ b/docs/features/os.md @@ -47,7 +47,8 @@ Output of any command can be displayed one page at a time using the [cmd2.Cmd.pp The pager is the command in `self.pager`, or `self.pager_chop` when chopping long lines: `less` on POSIX systems and `more` on Windows by default. If that program cannot be run, for example because it is not installed, the output is printed without paging. A pager command which could not be run is -not tried again while the application is running, so the shell reports it only once. +not tried again while the application is running. `self.pager` and `self.pager_chop` are separate +commands, so the shell may report each of them once. Alternatively, a terminal pager can be invoked directly using the ability to run shell commands with the `!` shortcut like so: diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 7091d67a4..a4183c767 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -4083,19 +4083,11 @@ def __rich_console__(self, console, options): yield from self._lines -@pytest.mark.parametrize("chop", [True, False]) -def test_ppaged_renders_once_when_the_pager_cannot_be_run(paging_app, chop) -> None: - """What was rendered for the pager is what gets shown: not everything can be rendered a second time.""" - app, shown = paging_app - app.pager = app.pager_chop = "cmd2-no-such-pager-program" - - app.ppaged(RendersOnce("first line", "second line"), chop=chop) - - assert shown() == "first line\nsecond line\n" - - def test_ppaged_does_not_try_again_a_pager_which_cannot_be_run(paging_app, capfd) -> None: - """The shell says once that there is no such pager, not every time something is paged.""" + """The shell says once that there is no such pager, not every time something is paged. + + From then on nothing is rendered for a pager either, only for poutput(). + """ app, shown = paging_app app.pager = "cmd2-no-such-pager-program"