MCPcopy Index your code
hub / github.com/python/cpython / test_smtp_policy

Method test_smtp_policy

Lib/test/test_email/test_generator.py:500–519  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

498 self.assertEqual(s.getvalue(), expected)
499
500 def test_smtp_policy(self):
501 msg = EmailMessage()
502 msg["From"] = Address(addr_spec="foo@bar.com", display_name="Páolo")
503 msg["To"] = Address(addr_spec="bar@foo.com", display_name="Dinsdale")
504 msg["Subject"] = "Nudge nudge, wink, wink"
505 msg.set_content("oh boy, know what I mean, know what I mean?")
506 expected = textwrap.dedent("""\
507 From: =?utf-8?q?P=C3=A1olo?= <foo@bar.com>
508 To: Dinsdale <bar@foo.com>
509 Subject: Nudge nudge, wink, wink
510 Content-Type: text/plain; charset="utf-8"
511 Content-Transfer-Encoding: 7bit
512 MIME-Version: 1.0
513
514 oh boy, know what I mean, know what I mean?
515 """).encode().replace(b"\n", b"\r\n")
516 s = io.BytesIO()
517 g = BytesGenerator(s, policy=policy.SMTP)
518 g.flatten(msg)
519 self.assertEqual(s.getvalue(), expected)
520
521
522if __name__ == '__main__':

Callers

nothing calls this directly

Calls 10

set_contentMethod · 0.95
getvalueMethod · 0.95
EmailMessageClass · 0.90
AddressClass · 0.90
BytesGeneratorClass · 0.90
replaceMethod · 0.45
encodeMethod · 0.45
dedentMethod · 0.45
flattenMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected