Add stderr/stdin stream control for console utilities.
Review Request #12246 — Created April 21, 2022 and submitted — Latest diff uploaded
This adds
stderr
andstdin
control forget_input()
,get_pass()
,
confirm()
, andconfirm_select()
utilities. When hooked up properly,
this enables unit tests to automate code paths that require user input.If
stdin
is a TTY, these will prompt the user for input as normal.
Otherwise, they'll read a line fromstdin
. This allows for scripting
inputs.While here, a few additional tweaks were made to these very old
utilities:
-
confirm()
no longer uses a private method indistutils
to check
for Yes/No input strings. Instead, the checks are now under our
control. -
confirm()
andconfirm_select()
now show bad user input in quotes.
Unit tests were also added for all these functions.
Unit tests pass.