MCPcopy
hub / github.com/django/django / test_localpart_only_address

Method test_localpart_only_address

tests/mail/tests.py:1472–1486  ·  view source on GitHub ↗

Django allows sending to a localpart-only email address (without @domain). This is not a valid RFC 822/2822/5322 addr-spec, but is accepted by some SMTP servers for local delivery. Regression for #15042.

(self)

Source from the content-addressed store, hash-verified

1470 self.assertEqual(message.get("cc"), "cc@xn--4ca9at.com")
1471
1472 def test_localpart_only_address(self):
1473 """
1474 Django allows sending to a localpart-only email address
1475 (without @domain). This is not a valid RFC 822/2822/5322 addr-spec, but
1476 is accepted by some SMTP servers for local delivery.
1477 Regression for #15042.
1478 """
1479 email = EmailMessage(from_email="django", to=["localpartonly"])
1480 parsed = message_from_bytes(email.message().as_bytes())
1481 self.assertEqual(
1482 parsed["From"].addresses, (Address(username="django", domain=""),)
1483 )
1484 self.assertEqual(
1485 parsed["To"].addresses, (Address(username="localpartonly", domain=""),)
1486 )
1487
1488 def test_lazy_addresses(self):
1489 """

Callers

nothing calls this directly

Calls 5

messageMethod · 0.95
EmailMessageClass · 0.90
message_from_bytesFunction · 0.85
as_bytesMethod · 0.80
AddressClass · 0.50

Tested by

no test coverage detected