So I want to write a script to run tests on my codes.
In my python file, I need to take inputs with the input()
method, type the input from the terminal, and my program then returns the output to the terminal.
But then I have a folder with testing files, file names like xx.in
and sample output for them xx.out
.
In my main program, I need to read inputs with input()
because it is a rule for my assignments. But in my testing scripts, can I read a file, store the data of that file in a buffer (or a stack?), then feed it to my program (line by line)?
Also, is there a way to write the output from print()
which prints to the terminal, but can store it in a file?
At last, the inputs are multi-line, and my program take each line with one input()
using a loop, and maybe print()
one line of results before it goes to next iteration and read input()
again, is there anything I need to take care about that part? Like will the line of input() be included into my output? I don't want it to happen.