(self)
| 118 | assert msg.get("Content-Type") == 'text/plain; charset="utf-8"' |
| 119 | |
| 120 | def test_send_attach_utf8(self): |
| 121 | subject = "sübjèçt" |
| 122 | body = "bödÿ-àéïöñß" |
| 123 | attach = BytesIO() |
| 124 | attach.write(body.encode("utf-8")) |
| 125 | attach.seek(0) |
| 126 | attachs = [("attachment", "text/plain", attach)] |
| 127 | |
| 128 | mailsender = MailSender(debug=True) |
| 129 | mailsender.send( |
| 130 | to=["test@scrapy.org"], |
| 131 | subject=subject, |
| 132 | body=body, |
| 133 | attachs=attachs, |
| 134 | charset="utf-8", |
| 135 | _callback=self._catch_mail_sent, |
| 136 | ) |
| 137 | |
| 138 | assert self.catched_msg |
| 139 | assert self.catched_msg["subject"] == subject |
| 140 | assert self.catched_msg["body"] == body |
| 141 | |
| 142 | msg = self.catched_msg["msg"] |
| 143 | assert msg["subject"] == subject |
| 144 | assert msg.get_charset() == Charset("utf-8") |
| 145 | assert msg.get("Content-Type") == 'multipart/mixed; charset="utf-8"' |
| 146 | |
| 147 | payload = msg.get_payload() |
| 148 | assert isinstance(payload, list) |
| 149 | assert len(payload) == 2 |
| 150 | |
| 151 | text, attach = payload |
| 152 | assert text.get_payload(decode=True).decode("utf-8") == body |
| 153 | assert text.get_charset() == Charset("utf-8") |
| 154 | assert attach.get_payload(decode=True).decode("utf-8") == body |
| 155 | |
| 156 | def test_create_sender_factory_with_host(self): |
| 157 | mailsender = MailSender(debug=False, smtphost="smtp.testhost.com") |
nothing calls this directly
no test coverage detected