I have a Django-based web application that is required to send a confirmation email to the user on an attempt to change the registered email address. The functionality has been implemented, but the lettuce test intended to verify the contents of the email is failing.
To verify the operation, my plan was to use the file backend (EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend') then verify the contents of the file within my lettuce step.
When running "normally" (e.g. via manage.py runserver), the email file is created as expected. When run via lettuce (manage.py harvest), the web site appears to be getting driven correctly (I'm using Selenium to drive it) but no email file is generated.
What have I missed? Is there some setting (e.g. in the terrain.py file) I need to use so the file backend is also used during the test process?
You can use
django.core.mail.outbox
as described in django docs https://docs.djangoproject.com/en/dev/topics/testing/#email-servicesLettuse uses
django.test.utils.setup_test_environment
that overrides email backend to the locmem email backend.