Add stderr/stdin stream control for console utilities.
Review Request #12246 — Created April 21, 2022 and submitted
confirm_select()utilities. When hooked up properly,
this enables unit tests to automate code paths that require user input.
stdinis a TTY, these will prompt the user for input as normal.
Otherwise, they'll read a line from
stdin. This allows for scripting
While here, a few additional tweaks were made to these very old
confirm()no longer uses a private method in
for Yes/No input strings. Instead, the checks are now under our
confirm_select()now show bad user input in quotes.
Unit tests were also added for all these functions.
Unit tests pass.
I need to spend a little more time thinking about how this interacts with things like piping a diff filename... ...
I need to spend a little more time thinking about how this interacts with things like piping a diff filename... There wouldn't be anything to read after consuming the diff (assuming we read it before invoking any of these commands), and we could then infinite loop on some of these...
This isn't necessarily a blocker for the other work I have in progress. I'll mull it over.
Fixed the prompt string type on all versions of Python.
We now cast to Unicode for writing. Tested in unit tests and with manual invocation on all versions.
Python 3 was using Unicode already. Python 2 auto-casts string types.
Revision 2 (+1036 -52)
Checks run (2 succeeded)