-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
testing/CliRunner: Fix regression related to EOF introduced in 262bdf0 #2940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing/CliRunner: Fix regression related to EOF introduced in 262bdf0 #2940
Conversation
fddeafc to
ab23822
Compare
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 pallets#2939.
ab23822 to
93c6966
Compare
Due to pallets/click#2939, input from a file is broken. This should be fixed by pallets/click#2940, which is scheduled to be in click 8.3.0.
Due to pallets/click#2939, input from a file is broken. This should be fixed by pallets/click#2940, which is scheduled to be in click 8.3.0.
|
Sorry @Rowlando13 for the late answer following your review request. But good call for merging this. I could not find a regression with the actual |
The latest `click` release makes two changes which are visible in
`pip-tools`, one of which is only seen in the testsuite.
1. The default for `Parameter.default` is now an internal `UNSET`
sentinel.
Because `UNSET` isn't in the public API, checking `Option.default`
is not the right way to check if an option has no explicit default
value. We could use `Option.to_info_dict()`, but we're *also*
checking for a falsy value right now -- the simple fix is to check
for a parsed value of `None`.
2. Changes to EOF handling in `CliRunner.isolation()` result in the
stream being closed on exit.
Between pallets/click#2934 and pallets/click#2940, we now get the
intended behavior for `CliRunner.isolation()`, in that it outputs an
EOF when the context manager exits. To solve, update a test to read
stderr before exiting the context manager.
The latest `click` release makes two changes which are visible in
`pip-tools`, one of which is only seen in the testsuite.
1. The default for `Parameter.default` is now an internal `UNSET`
sentinel.
Because `UNSET` isn't in the public API, checking `Option.default`
is not the right way to check if an option has no explicit default
value. We could use `Option.to_info_dict()`, but we're *also*
checking for a falsy value right now -- the simple fix is to check
for a parsed value of `None`.
2. Changes to EOF handling in `CliRunner.isolation()` result in the
stream being closed on exit.
Between pallets/click#2934 and pallets/click#2940, we now get the
intended behavior for `CliRunner.isolation()`, in that it outputs an
EOF when the context manager exits. To solve, update a test to read
stderr before exiting the context manager.
| - 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` |
There was a problem hiding this comment.
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 ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit 262bdf0 ensured to raise an
EOFErrorexception 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
Filetype option or argument and when it is set tostdin: the command ends up with error due to theAbortexception being raised when the stdinEOFErrorexception is caught.To prevent this undesirable side effect, prefer to raise the
EOFErrorexceptions directly from the prompts functions inside theCliRunnerclass instead of doing it in the method overriding the iterator protcol for the_NamedTextIOWrapperclass.Restore previous implementation of a test broken by changes of 262bdf0.
Fixes #2939.