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

Method testSourceAddress

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

Source from the content-addressed store, hash-verified

286 smtp.quit()
287
288 def testSourceAddress(self):
289 # connect
290 src_port = socket_helper.find_unused_port()
291 try:
292 smtp = smtplib.SMTP(self.host, self.port, local_hostname='localhost',
293 timeout=support.LOOPBACK_TIMEOUT,
294 source_address=(self.host, src_port))
295 self.addCleanup(smtp.close)
296 self.assertEqual(smtp.source_address, (self.host, src_port))
297 self.assertEqual(smtp.local_hostname, 'localhost')
298 smtp.quit()
299 except OSError as e:
300 if e.errno == errno.EADDRINUSE:
301 self.skipTest("couldn't bind to source port %d" % src_port)
302 raise
303
304 def testNOOP(self):
305 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',

Callers

nothing calls this directly

Calls 4

quitMethod · 0.95
addCleanupMethod · 0.80
skipTestMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected