I am trying to redirect of print statement of reporterror
function into file but output of print statement did not redirect into text file
May I know what am i missing here
Please note I have created one live scenario here and I can not modify report
error function as it's in framework and modificaition will require lot of testing
import os
def reporterror():
print ("file not found")
errors = ["error", "error1", "error3"]
for er in errors:
print (er)
return 1
def info():
print (os.getcwd())
with open("info.txt", "w") as finfo:
print(reporterror(), file=finfo)
info()
Output in .txt file:
1
Expected output:
error
error1
error2