I am trying to pass the test result from my test1
and test2
function, to the save_results
function, so I can write the result to an Excel file, how should I change my code to achieve that?
import os
import xlswriter
from datetime import datetime
import time
def save_results():
os.chdir(r'C:\Users\user\Documents\Results')
workbook = xlsxwriter.Workbook(datetime_output_results+'.xlsx')
worksheet = workbook.add_worksheet()
bold = workbook.add_format({'bold': True})
worksheet.set_column('A:A', 20)
worksheet.write('A1', 'here i would like to write the test1 result')
#worksheet.write('B1','here i would like to write the test2 result')
workbook.close()
def test1():
output = str(ser.read(1000).decode())
output = str(output)
if "0x1" in output :
print('Pass')
return 'Pass'
else:
print('Fail')
return 'Fail'
def test2():
output2 = str(ser.read(1000).decode())
print(output2)
test2_output = str(output2)
if "0x1" in test2_output:
print('Pass')
return 'Pass'
else:
print('Fail')
return 'Fail'
from How to pass a string variable from one function to another?
No comments:
Post a Comment