From 3a2d1cbcf537021a3b72adc1e2c9b8a20d99e18d Mon Sep 17 00:00:00 2001 From: John Andersen Date: Tue, 7 Dec 2021 20:43:40 -0800 Subject: [PATCH] util: testing: consoletest: commands: Allow reading from stdin if CONSOLETEST_STDIN environment variable is set Signed-off-by: John Andersen --- dffml/util/testing/consoletest/commands.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dffml/util/testing/consoletest/commands.py b/dffml/util/testing/consoletest/commands.py index 961c920541..60090422fd 100644 --- a/dffml/util/testing/consoletest/commands.py +++ b/dffml/util/testing/consoletest/commands.py @@ -287,7 +287,11 @@ async def run_commands( # Set stdout to system stdout so it doesn't go to the pty kwargs["stdout"] = stdout if stdout is not None else sys.stdout # Check if there is a previous command - kwargs["stdin"] = stdin if stdin is not None else subprocess.DEVNULL + kwargs["stdin"] = ( + stdin + if (stdin is not None or os.environ.get("CONSOLETEST_STDIN", "")) + else subprocess.DEVNULL + ) if i != 0: # NOTE asyncio.create_subprocess_exec doesn't work for piping output # from one process to the next. It will complain about stdin not