click icon indicating copy to clipboard operation
click copied to clipboard

testing/CliRunner: Fix regression related to EOF introduced in 262bdf0

Open anlambert opened this issue 8 months ago • 0 comments

Commit 262bdf0 ensured to raise an EOFError exception on end of input to simulate tty behavior and avoid blocking prompt during tests when no more input is available.

However the introduced implementation has a side effect when testing a click command having a File type option or argument and when it is set to stdin: the command ends up with error due to the Abort exception being raised when the stdin EOFError exception is caught.

To prevent this undesirable side effect, prefer to raise the EOFError exceptions directly from the prompts functions inside the CliRunner class instead of doing it in the method overriding the iterator protcol for the _NamedTextIOWrapper class.

Restore previous implementation of a test broken by changes of 262bdf0.

Fixes #2939.

anlambert avatar May 22 '25 20:05 anlambert