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

Method testSendMessage

Lib/test/test_smtplib.py:494–514  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

492 self.assertRegex(debugout, sender)
493
494 def testSendMessage(self):
495 m = email.mime.text.MIMEText('A test message')
496 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
497 timeout=support.LOOPBACK_TIMEOUT)
498 self.addCleanup(smtp.close)
499 smtp.send_message(m, from_addr='John', to_addrs='Sally')
500 # XXX (see comment in testSend)
501 time.sleep(0.01)
502 smtp.quit()
503
504 self.client_evt.set()
505 self.serv_evt.wait()
506 self.output.flush()
507 # Remove the X-Peer header that DebuggingServer adds as figuring out
508 # exactly what IP address format is put there is not easy (and
509 # irrelevant to our test). Typically 127.0.0.1 or ::1, but it is
510 # not always the same as socket.gethostbyname(HOST). :(
511 test_output = self.get_output_without_xpeer()
512 del m['X-Peer']
513 mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
514 self.assertEqual(test_output, mexpect)
515
516 def testSendMessageWithAddresses(self):
517 m = email.mime.text.MIMEText('A test message')

Callers

nothing calls this directly

Calls 10

send_messageMethod · 0.95
quitMethod · 0.95
addCleanupMethod · 0.80
sleepMethod · 0.45
setMethod · 0.45
waitMethod · 0.45
flushMethod · 0.45
as_stringMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected