MCPcopy
hub / github.com/django/django / test_attach_utf8_text_as_bytes

Method test_attach_utf8_text_as_bytes

tests/mail/tests.py:1070–1080  ·  view source on GitHub ↗

Non-ASCII characters encoded as valid UTF-8 are correctly transported in a form that can be decoded at the receiving end.

(self)

Source from the content-addressed store, hash-verified

1068 )
1069
1070 def test_attach_utf8_text_as_bytes(self):
1071 """
1072 Non-ASCII characters encoded as valid UTF-8 are correctly transported
1073 in a form that can be decoded at the receiving end.
1074 """
1075 msg = EmailMessage()
1076 msg.attach("file.txt", b"\xc3\xa4\n") # UTF-8 encoded a-umlaut.
1077 filename, content, mimetype = self.get_decoded_attachments(msg)[0]
1078 self.assertEqual(filename, "file.txt")
1079 self.assertEqual(content, "ä\n") # (decoded)
1080 self.assertEqual(mimetype, "text/plain")
1081
1082 def test_attach_non_utf8_text_as_bytes(self):
1083 """

Callers

nothing calls this directly

Calls 3

attachMethod · 0.95
EmailMessageClass · 0.90

Tested by

no test coverage detected