From 16b8e3afd89d2f19d95e7623cde78ad1afb34f0e Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Sun, 8 Jul 2012 10:37:33 -0400 Subject: [PATCH] Don't rely on app_config if common.TESTS_ENABLED. app_config will be None in this case, so all of these subscripts will fail. --- mediagoblin/tools/mail.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mediagoblin/tools/mail.py b/mediagoblin/tools/mail.py index 655d5b99..8639ba0c 100644 --- a/mediagoblin/tools/mail.py +++ b/mediagoblin/tools/mail.py @@ -98,8 +98,9 @@ def send_email(from_addr, to_addrs, subject, message_body): if not mg_globals.app_config['email_smtp_host']: # e.g. host = '' mhost.connect() # We SMTP.connect explicitly - if mg_globals.app_config['email_smtp_user'] \ - or mg_globals.app_config['email_smtp_pass']: + if ((not common.TESTS_ENABLED) + and (mg_globals.app_config['email_smtp_user'] + or mg_globals.app_config['email_smtp_pass'])): mhost.login( mg_globals.app_config['email_smtp_user'], mg_globals.app_config['email_smtp_pass']) @@ -112,7 +113,7 @@ def send_email(from_addr, to_addrs, subject, message_body): if common.TESTS_ENABLED: EMAIL_TEST_INBOX.append(message) - if mg_globals.app_config['email_debug_mode']: + elif mg_globals.app_config['email_debug_mode']: print u"===== Email =====" print u"From address: %s" % message['From'] print u"To addresses: %s" % message['To']