When echo_via_pager is used in the command, CliRunner.invoke fails with:
ValueError: I/O operation on closed file.
This started happening with Click 8.4, does not happen with 8.3.3.
Reproducer:
from click import command, echo_via_pager
from click.testing import CliRunner
@command()
def cli():
echo_via_pager("Hello, Click!")
runner = CliRunner()
runner.invoke(cli)
Traceback:
Traceback (most recent call last):
File ".../echo_via_pager.py", line 11, in <module>
runner.invoke(cli)
~~~~~~~~~~~~~^^^^^
File ".../.venv/echo-via-pager/lib/python3.13/site-packages/click/testing.py", line 676, in invoke
sys.stdout.flush()
~~~~~~~~~~~~~~~~^^
ValueError: I/O operation on closed file.
Environment:
- OS: Ubuntu 24.04.4, Linux 6.17
- Python version: 3.13.5
- Click version: 8.4
When
echo_via_pageris used in the command,CliRunner.invokefails with:This started happening with Click 8.4, does not happen with 8.3.3.
Reproducer:
Traceback:
Environment: