Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Unreleased
- Lazily import ``shutil``. :pr:`3023`
- Properly forward exception information to resources registered with
``click.core.Context.with_resource()``. :issue:`2447` :pr:`3058`
- Fix regression related to EOF handling in CliRunner. :issue:`2939`:pr:`2940`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lacking whitespace in between two refs ^

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Version 8.2.2
-------------
Expand Down
17 changes: 8 additions & 9 deletions src/click/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ def name(self) -> str:
def mode(self) -> str:
return self._mode

def __next__(self) -> str: # type: ignore
try:
line = super().__next__()
except StopIteration as e:
raise EOFError() from e
return line


def make_input_stream(
input: str | bytes | t.IO[t.Any] | None, charset: str
Expand Down Expand Up @@ -359,7 +352,10 @@ def isolation(
@_pause_echo(echo_input) # type: ignore
def visible_input(prompt: str | None = None) -> str:
sys.stdout.write(prompt or "")
val = next(text_input).rstrip("\r\n")
try:
val = next(text_input).rstrip("\r\n")
except StopIteration as e:
raise EOFError() from e
sys.stdout.write(f"{val}\n")
sys.stdout.flush()
return val
Expand All @@ -368,7 +364,10 @@ def visible_input(prompt: str | None = None) -> str:
def hidden_input(prompt: str | None = None) -> str:
sys.stdout.write(f"{prompt or ''}\n")
sys.stdout.flush()
return next(text_input).rstrip("\r\n")
try:
return next(text_input).rstrip("\r\n")
except StopIteration as e:
raise EOFError() from e

@_pause_echo(echo_input) # type: ignore
def _getchar(echo: bool) -> str:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def processor(iterator):
return processor

result = runner.invoke(cli, args, input=input)
# last two lines are '' and 'Aborted!'
assert result.output.splitlines()[:-2] == expect
assert not result.exception
assert result.output.splitlines() == expect


def test_args_and_chain(runner):
Expand Down
Loading