Is there a way to simulate stdin in Mojo?

I wrote a basic input() function and created an automated test script on GH but want to add tests to the input() function. Because of this, I'd like to be able to feed a pre-made answer into the stdin, is this possible? The input() function:
from python import Python, PythonObject

fn input(prompt: StringLiteral) -> String:
try:
let builtins = Python.import_module("builtins")
let input_function = builtins.input
let user_input: PythonObject = input_function(String(prompt))
return user_input.to_string()
except:
return String("")
from python import Python, PythonObject

fn input(prompt: StringLiteral) -> String:
try:
let builtins = Python.import_module("builtins")
let input_function = builtins.input
let user_input: PythonObject = input_function(String(prompt))
return user_input.to_string()
except:
return String("")
This is especially important to me as I couldn't get the containers in VS Code to work and need to rely on these automated tests until native support arrives.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server