[pull] main from django:main#403
Merged
Merged
Conversation
* Renamed shared backend test case class to SharedEmailBackendTests, to avoid confusion with tests for the BaseEmailBackend. * Used consistent module references to mail functions (removed `mail.` from most uses; kept it for `mail.get_connection()`). * Used consistent `backend` variable name for EmailBackend instances in backend tests (matching most SMTP tests, replacing `connection` and `conn` in other tests). * Renamed some test cases for clarity. * Removed some unnecessary docstrings from test cases. * Reformatted some docstrings with nearby edits.
* Removed unnecessary empty username/password args and unnecessary test
email content.
* Replaced monkeypatching with mock.patch. Minimized scope of patches.
* Added missing assertions in some tests.
* Cleaned up uses of assertTrue() and assertFalse().
* Removed implicit assumption in LocmemBackendTests that mail is always
sent by the locmem backend during tests.
* Made FileBackendTests tmp_dir cleanup more robust, and added helpers
to simplify test cases.
* Split FileBackendTests.test_sessions() into three distinct cases (and
removed unrelated, duplicative verification of message content).
* Used mock to simplify and improve accuracy of SMTP AUTH test.
* Replaced `get_connection("mail.custombackend.EmailBackend")` with
direct `custombackend.EmailBackend()` construction to avoid soon-to-
be-deprecated usage of `get_connection(backend_path)` in cases that
aren't trying to test creating a connection from an import path.
Added tests for: * BaseEmailBackend class. * EmailBackend support for fail_silently arg and unknown kwargs. * File backend support for EMAIL_FILE_PATH setting. * File backend configuration error reporting (where possible). * SMTP backend support for EMAIL_HOST and EMAIL_PORT settings. * SMTP backend use of ssl_certfile, ssl_keyfile, timeout options. * send_mail() return value. * send_mass_mail() basic behavior. * send_mail() and send_mass_mail() support for auth_user, auth_password, and fail_silently args. * get_connection() support for EMAIL_BACKEND setting and backend-specfic kwargs.
Replaced TypeError in `os.path.abspath(None)` with ImproperlyConfigured error when settings.EMAIL_FILE_PATH is required but missing.
Added missing test to verify Django's test runner swaps in the locmem EmailBackend during tests. Extracted reusable mock_test_state() helper from SetupTestEnvironmentTests.test_allowed_hosts().
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )