I wrote some tests for a simple python application that takes data from a form, checks for valid data, and sends it to an email address. My tests all pass locally, but they fail when ran with travis-ci. The error seems to be caused when I try to instantiate an SMTP object so I can send the email.
Here is the code that is causing travis to fail:
def send_email(self, msg):
msg_send = MIMEText(str(msg))
s = smtplib.SMTP('localhost')
try:
s.sendmail('theform', EMAIL, msg_send.as_string())
s.quit()
except:
s.quit()
When I build with travis, I get this:
======================================================================
ERROR: test_send_email (__main__.TestFormsender)
----------------------------------------------------------------------
Traceback (most recent call last):
File "werkzeug_test.py", line 83, in test_send_email
real.send_email(msg)
File "/home/travis/build/osuosl/formsender/request_handler.py", line 46, in send_email
s = smtplib.SMTP('localhost')
File "/opt/python/2.7.9/lib/python2.7/smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "/opt/python/2.7.9/lib/python2.7/smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/opt/python/2.7.9/lib/python2.7/smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "/opt/python/2.7.9/lib/python2.7/socket.py", line 571, in create_connection
raise err
error: [Errno 111] Connection refused
I tried running the app on localhost while running travis, but it still didn't work. Does anyone know what is happening here?
Aucun commentaire:
Enregistrer un commentaire