summaryrefslogtreecommitdiff
path: root/tests/auth_tests
diff options
context:
space:
mode:
authorMike Edmunds <medmunds@gmail.com>2026-04-14 12:43:07 -0700
committernessita <124304+nessita@users.noreply.github.com>2026-05-06 22:39:16 -0300
commit21dcd9a94fb3e9edeec883d12cd1dcac5e773abe (patch)
tree07dd3abcfc50cd4a1f9ef9692e1550c3670c396f /tests/auth_tests
parenta276941334624994928c0547eebff4595c5e5532 (diff)
Refs #35514 -- Cleaned up logging and middleware tests.
Simplified and removed use of soon-to-be-deprecated or removed features from tests for AdminEmailHandler and BrokenLinkEmailsMiddleware. Added or updated cases to ensure `fail_silently` usage remains consistent during the transition to email providers. Changed custom FailingEmailBackend to respect fail_silently and record its use in a class-level property. In AdminEmailHandlerTest: * Added make_log_record() helper to reduce duplicated code. * Changed test_fail_silently() to send through the FailingEmailBackend, which will fail if not initialized with fail_silently=True. (Rather than inspecting attributes of a soon-to-be-deprecated connection.) * Simplified test_uses_custom_email_backend() by replacing monkeypatches with inspectable custom backend. * In test_customize_send_mail_method(), removed use of the undocumented self.connection() method and the soon-to-be-deprecated `connection` arg to mail_managers(). This test verifies a subclass can customize sending by mailing the managers rather than the admins. Involving a email backend connection was irrelevant. In BrokenLinkEmailsMiddlewareTest, added a case with FailingEmailBackend to verify send uses fail_silently=True.
Diffstat (limited to 'tests/auth_tests')
-rw-r--r--tests/auth_tests/test_forms.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
index 983fe8c39e..167722c617 100644
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -4,6 +4,8 @@ import sys
import urllib.parse
from unittest import mock
+from mail.custombackend import FailingEmailBackend
+
from django import forms
from django.contrib.auth.forms import (
AdminPasswordChangeForm,
@@ -1382,6 +1384,7 @@ class PasswordResetFormTest(TestDataMixin, TestCase):
@override_settings(EMAIL_BACKEND="mail.custombackend.FailingEmailBackend")
def test_save_send_email_exceptions_are_catched_and_logged(self):
+ self.addCleanup(FailingEmailBackend.reset)
user, username, email = self.create_dummy_user()
form = PasswordResetForm({"email": email})
self.assertTrue(form.is_valid())