python - Can't access outbox while testing with lettuce -


i using lettuce test 1 of applications.

i testing module check if can send emails.

i did research , found in django documentation easy way test it.

from django.core import mail django.test import testcase  class emailtest(testcase):     def test_send_email(self):         # send message.         mail.send_mail('subject here', 'here message.',             'from@example.com', ['to@example.com'],             fail_silently=false)          # test 1 message has been sent.         self.assertequal(len(mail.outbox), 1)          # verify subject of first message correct.         self.assertequal(mail.outbox[0].subject, 'subject here') 

the problem keep getting error attributeerror: 'module' object has no attribute 'outbox'.

from found, problem here

the django server runs in different process lettuce scripts, make outbox inaccessible.

i did more research , found possible solution here.

the guy says this:

# in terrain.py lettuce import before, after, world django.conf import settings  @before.handle_request     def override_mail_settings(httpd, server):         settings.email_backend = 'django.core.mail.backends.filebased.emailbackend' 

but don't know terrain.py equivalent.i tried in steps.py file, didn't work.

does know how fix this?

i managed find here answer problem after more research.

the thing had edit settings.py , add line:

email_backend = 'django.core.mail.backends.locmem.emailbackend' 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -