-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_dj_autoclear_mailbox ends quite often with AttributeError: module 'django.core.mail' has no attribute 'outbox' #993
Comments
Based on Django documentation: During test running, each outgoing email is saved in django.core.mail.outbox. This is a list of all EmailMessage instances that have been sent. The outbox attribute is a special attribute that is created only when the locmem email backend is used. It doesn’t normally exist as part of the django.core.mail module and you can’t import it directly. Could you please add a test to show in what condition the above mentioned error happens? |
The above error is from running test suite of https://github.com/evansd/whitenoise Complete build log contains records of all packages used and steps taken. |
@evansd Does this whole ticket make sense to you? |
This sounds like an incompatibility between the versions of Django and pytest-django being used and nothing specific to whitenoise. |
Im having the Same errors, i created a custom |
I see the same issue occurring recently. Note that the error occurs in the I my case, it occurs in a project in which Django is set up manually because the project only needs to be able to generated html based on Django templates. For testing, the Django instance is set up as follows:
Note that I can avoid the issue by adding the following in my root
|
Reproduced with Django 4.2.7 with no settings configuration. For me, I happened to have Django in my venv but had not configured a settings in this particular test slice and ran into the exception. Thanks @wouter-vd, your workaround did indeed fix it! |
When running the test suite for whitenoise plenty of tests ends with the following error (using pytest-6.2.5, pytest-django-4.5.2):
When reading on the
mail.outbox
I found that it doesn’t exist quite often, so this fixture has protection against it. When I apply this patch:Tests pass without a problem.
The text was updated successfully, but these errors were encountered: