Regression for #12791 - Encode body correctly with other encodings than utf-8
(self)
| 832 | self.assertIn("@xn--p8s937b>", message["Message-ID"]) |
| 833 | |
| 834 | def test_encoding(self): |
| 835 | """ |
| 836 | Regression for #12791 - Encode body correctly with other encodings |
| 837 | than utf-8 |
| 838 | """ |
| 839 | email = EmailMessage(body="Firstname Sürname is a great guy.\n") |
| 840 | email.encoding = "iso-8859-1" |
| 841 | message = email.message() |
| 842 | self.assertEqual(message["Content-Type"], 'text/plain; charset="iso-8859-1"') |
| 843 | |
| 844 | # Check that body is actually encoded with iso-8859-1. |
| 845 | msg_bytes = message.as_bytes() |
| 846 | self.assertEqual(message["Content-Transfer-Encoding"], "8bit") |
| 847 | self.assertIn(b"Firstname S\xfc", msg_bytes) |
| 848 | parsed = message_from_bytes(msg_bytes) |
| 849 | self.assertEqual(parsed.get_content(), "Firstname Sürname is a great guy.\n") |
| 850 | |
| 851 | def test_encoding_alternatives(self): |
| 852 | """ |
nothing calls this directly
no test coverage detected