(self)
| 514 | self.assertEqual(test_output, mexpect) |
| 515 | |
| 516 | def testSendMessageWithAddresses(self): |
| 517 | m = email.mime.text.MIMEText('A test message') |
| 518 | m['From'] = 'foo@bar.com' |
| 519 | m['To'] = 'John' |
| 520 | m['CC'] = 'Sally, Fred' |
| 521 | m['Bcc'] = 'John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>' |
| 522 | smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', |
| 523 | timeout=support.LOOPBACK_TIMEOUT) |
| 524 | self.addCleanup(smtp.close) |
| 525 | smtp.send_message(m) |
| 526 | # XXX (see comment in testSend) |
| 527 | time.sleep(0.01) |
| 528 | smtp.quit() |
| 529 | # make sure the Bcc header is still in the message. |
| 530 | self.assertEqual(m['Bcc'], 'John Root <root@localhost>, "Dinsdale" ' |
| 531 | '<warped@silly.walks.com>') |
| 532 | |
| 533 | self.client_evt.set() |
| 534 | self.serv_evt.wait() |
| 535 | self.output.flush() |
| 536 | # Remove the X-Peer header that DebuggingServer adds. |
| 537 | test_output = self.get_output_without_xpeer() |
| 538 | del m['X-Peer'] |
| 539 | # The Bcc header should not be transmitted. |
| 540 | del m['Bcc'] |
| 541 | mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END) |
| 542 | self.assertEqual(test_output, mexpect) |
| 543 | debugout = smtpd.DEBUGSTREAM.getvalue() |
| 544 | sender = re.compile("^sender: foo@bar.com$", re.MULTILINE) |
| 545 | self.assertRegex(debugout, sender) |
| 546 | for addr in ('John', 'Sally', 'Fred', 'root@localhost', |
| 547 | 'warped@silly.walks.com'): |
| 548 | to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr), |
| 549 | re.MULTILINE) |
| 550 | self.assertRegex(debugout, to_addr) |
| 551 | |
| 552 | def testSendMessageWithSomeAddresses(self): |
| 553 | # Make sure nothing breaks if not all of the three 'to' headers exist |
nothing calls this directly
no test coverage detected