summaryrefslogtreecommitdiff
path: root/tests/mail/tests.py
AgeCommit message (Collapse)Author
2025-01-31[5.2.x] Fixed #36119 -- Fixed UnicodeEncodeError when attaching a file with ↵greg
8bit Content-Transfer-Encoding. Backport of 89e28e13ecbf9fbcf235e16d453c08bbf2271244 from main.
2024-12-03Refs #35581 -- Added tests for email parameters, attachments, MIME ↵Mike Edmunds
structure, bcc header, encoding and sending.
2024-12-03Refs #35581 -- Used modern email parser and helpers in mail tests.Mike Edmunds
- Used modern email API (policy.default) for tests that reparse generated messages, and switched to modern accessors where helpful. - Split get_raw_attachments() helper out of get_decoded_attachments(), and used modern iter_attachments() to avoid finding nested attachments in attached message/* emails. - Stopped using legacy parseaddr.
2024-12-03Refs #35581 -- Improved reporting for failing tests in mail tests.Mike Edmunds
- Converted HeadersCheckMixin to MailTestsMixin for all shared helpers: - Hoisted assertStartsWith() from BaseEmailBackendTests. - Added matching assertEndsWith(). - Hoisted get_decoded_attachments() from MailTests. - Improved failure reporting in assertMessageHasHeaders(). - Used unittest subTest() to improve handling of compound test cases. - Replaced `assertTrue(test on string)` with custom assertions, so that failure reporting is more informative than `True != False`.
2024-10-29Refs #35581 -- Reduced boilerplate in mail tests.Mike Edmunds
2024-10-29Refs #35581 -- Identified mail tests that check for Python 2 behavior.Mike Edmunds
This also removed a duplicate CTE case (that used to be distinct in Python 2).
2024-10-29Refs #35581 -- Verified attachments in the generated message in mail tests.Mike Edmunds
This also removed send() calls, as this doesn't check the serialized content, and the backend tests cover sending.
2024-10-29Refs #35581 -- Clarified some test names and comments in mail tests.Mike Edmunds
2024-08-05Refs #35537 -- Improved documentation and test coverage for email ↵Jake Howard
attachments and alternatives.
2024-07-11Fixed #35033, Refs #28912 -- Fixed repeated headers in EmailMessage.Mike Edmunds
Fixed a regression which would cause multiple To, Cc, and Reply-To headers in the result of EmailMessage.message() if values were supplied for both to/cc/reply_to and the corresponding extra_headers fields. Updated related tests to check the generated message() has exactly one of each expected header using get_all(). Regression in b03d5002955256c4b3ed7cfae5150eb79c0eb97e.
2024-06-21Fixed #35528 -- Added EmailMultiAlternatives.body_contains() helper method.Ronny Vedrilla
2024-06-20Fixed #35537 -- Changed EmailMessage.attachments and ↵Jake Howard
EmailMultiAlternatives.alternatives to use namedtuples. This makes it more descriptive to pull out the named fields.
2024-06-14Fixed mail.tests.MailTests.test_backend_arg() test on Python 3.13+.Mariusz Felisiak
There is no point in asserting Python error messages.
2024-04-10Refs #35361 -- Added test for Email line length checks when dealing with ↵Natalia
surrogate pairs. Refs #33173, #34118 and #34900.
2024-01-26Applied Black's 2024 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/24.1.0
2024-01-04Used enterClassContext() where appropriate.Mariusz Felisiak
2023-12-31Used addCleanup() in tests where appropriate.Mariusz Felisiak
2023-10-25Fixed #34904 -- Prevented mutating sent emails from outbox in locmem email ↵sindre
backend.
2023-07-17Refs #34118 -- Improved sanitize_address() error message for tuple with ↵Mariusz Felisiak
empty strings.
2022-11-10Updated documentation and comments for RFC updates.Nick Pope
- Updated references to RFC 1123 to RFC 5322 - Only partial as RFC 5322 sort of sub-references RFC 1123. - Updated references to RFC 2388 to RFC 7578 - Except RFC 2388 Section 5.3 which has no equivalent. - Updated references to RFC 2396 to RFC 3986 - Updated references to RFC 2616 to RFC 9110 - Updated references to RFC 3066 to RFC 5646 - Updated references to RFC 7230 to RFC 9112 - Updated references to RFC 7231 to RFC 9110 - Updated references to RFC 7232 to RFC 9110 - Updated references to RFC 7234 to RFC 9111 - Tidied up style of text when referring to RFC documents
2022-02-19Refs #33173 -- Fixed MailTests.test_backend_arg() on Windows and Python 3.11+.David Smith
2022-02-07Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-10-15Refs #32074 -- Removed usage of deprecated asyncore and smtpd modules.Mariusz Felisiak
asyncore and smtpd modules were deprecated in Python 3.10.
2021-10-14Refs #27131 -- Removed SMTPBackendTests.test_server_login().Mariusz Felisiak
test_server_login() was a regression test for a crash when passing Unicode strings to SMTP server using CRAM-MD5 method on Python 2. Python 2 is no longer supported and test_server_login() passes even without FakeSMTPChannel.smtp_AUTH() because smtplib.SMTPAuthenticationError is raised when AUTH is not implemented.
2021-06-04Refs #32355 -- Used addClassCleanup() in tests.Mariusz Felisiak
Inspired by Adam Johnson talk on DjangoCon Europe 2021.
2021-03-19Refs #32508 -- Raised Type/ValueError instead of using "assert" in django.core.Daniyal
2020-08-07Used mock.Mock() in SMTPBackendTests.Konstantin Alekseev
Using bool caused mypy typecheck failures.
2020-07-20Fixed #31784 -- Fixed crash when sending emails on Python 3.6.11+, 3.7.8+, ↵Florian Apolloner
and 3.8.4+. Fixed sending emails crash on email addresses with display names longer then 75 chars on Python 3.6.11+, 3.7.8+, and 3.8.4+. Wrapped display names were passed to email.headerregistry.Address() what caused raising an exception because address parts cannot contain CR or LF. See https://bugs.python.org/issue39073 Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-07-20Refs #31784 -- Added test for preventing header injection in display name of ↵Mariusz Felisiak
email addresses.
2020-04-20Capitalized Unicode in docs, strings, and comments.Jon Dufresne
2019-11-06Adjusted expected exception message for Windows.Jon Dufresne
Test failure introduced in fbbff7f80870bc3e98de4a2fc9cd853949842fd0. Windows uses a different error message when a non-path is passed to os.path functions.
2019-11-06Refs #29983 -- Added pathlib.Path support to the file email backend.Jon Dufresne
2019-07-03Fixed #30608 -- Fixed non-unicode EmailMessage crash when domain name for ↵Chason Chaffin
localhost is non-ASCII. Assisted by felixxm.
2019-07-02Fixed #30604 -- Made mail_admins()/mail_managers() raise ValueError if ↵Hasan Ramezani
ADMINS/MANAGERS is set incorrectly.
2019-06-13Refs #30512, #15042 -- Added local-only address to sanitize_email() tests cases.Carlton Gibson
email.headerregistry.parser.get_mailbox() returns a token with a `token_type` attribute. If `token_type` is `’invalid-mailbox’` then RFC violations have been detected. Emails with only the local part, and no domain, are correctly parsed but are marked as `’invalid-mailbox’`. As per #15042, local-only are supported, to enable sending to addresses on localhost. sanitize_email() does not currently check `token_type`. This test is added to avoid a regression in case this is revisited in the future.
2019-06-13Fixed #30512 -- Used email.headerregistry.parser for parsing emails in ↵Joachim Jablon
sanitize_address().
2019-06-06Refs #30512 -- Added tests for sanitizing email addresses with display name ↵Joachim Jablon
and two @ signs.
2019-06-06Refs #30512 -- Used subTest() in MailTests.test_sanitize_address.Joachim Jablon
2019-02-09Removed uneeded generator expressions and list comprehensions.Sergey Fedoseev
2019-01-30Fixed #30116 -- Dropped support for Python 3.5.Tim Graham
2019-01-28Fixed #30137 -- Replaced OSError aliases with the canonical OSError.Jon Dufresne
Used more specific errors (e.g. FileExistsError) as appropriate.
2019-01-02Used 4 space hanging indent for dictionaries.Tim Graham
Thanks Mariusz Felisiak for auditing.
2018-12-26Fixed #30058 -- Made SMTP EmailBackend.send_messages() return 0 for ↵Denis Stebunov
empty/error cases.
2018-10-22Fixed #29830 -- Fixed loss of custom utf-8 body encoding in mails.jannschu
2018-08-04Removed unnecessary str() in mail tests.Tim Graham
Unnecessary since their introduction in fa75b2cb512409116b6f1b5229d6f99074d8e452.
2018-03-16Fixed hanging indentation in various code.Mariusz Felisiak
2018-02-20Fixed #29140 -- Fixed EmailMessage crash when body is None.Williams Mendez
2018-02-07Refs #27795 -- Removed force_bytes/text() usage in tests.Tim Graham
2018-01-15Added a few tests for smtp EmailBackend.Mads Jensen