← Back to team overview

sikuli-driver team mailing list archive

[Question #207362]: Error while trying to send test results through email

 

New question #207362 on Sikuli:
https://answers.launchpad.net/sikuli/+question/207362

Hello,

Maybe this is not a Sikuli problem but a Python one, so sorry if question is misplaced! Here is my problem :
I have written a script that runs a suite of 4 test cases, creates Test Results with HTML Test Runner and puts results in a file. Fine till here. Then I am using a function found in python takes the file as an attachment and sends it through email :

def sendMail(to, subject, text, files=[],server="localhost"):
    assert type(to)==list
    assert type(files)==list
    
    fro = "Test Name <test@xxxxxxxx>"
    msg = MIMEMultipart()
    msg['From'] = fro
    msg['To'] = COMMASPACE.join(to)
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject
    
    msg.attach( MIMEText(text) )
    for file in files:
        part = MIMEBase('application', "octet-stream")
        part.set_payload( open(file,"rb").read() )
        Encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(file))
        msg.attach(part)
    smtp = smtplib.SMTP(server)
    smtp.sendmail(fro, to, msg.as_string() )
    smtp.close()

sendMail(["test@xxxxxxxx"],"hello","cheers",["C:\Report.html"])

The problem is that when the function runs I get the below error :

 assert type(to)==list
TypeError: type(): 1st arg can't be coerced to String

Why can't it take "test@xxxxxxxx" as a String? Any suggestions?
Thank you!

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.