当前位置: 首页>>代码示例>>Python>>正文


Python mock_socket.reply_with函数代码示例

本文整理汇总了Python中test.mock_socket.reply_with函数的典型用法代码示例。如果您正苦于以下问题:Python reply_with函数的具体用法?Python reply_with怎么用?Python reply_with使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了reply_with函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testSourceAddress

 def testSourceAddress(self):
     mock_socket.reply_with(b"220 Hola mundo")
     # connects
     smtp = smtplib.SMTP(HOST, self.port,
             source_address=('127.0.0.1',19876))
     self.assertEqual(smtp.source_address, ('127.0.0.1', 19876))
     smtp.close()
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:7,代码来源:test_smtplib.py

示例2: setUp

 def setUp(self):
     smtplib.socket = mock_socket
     mock_socket.reply_with(b"199 no hello for you!")
     self.old_stdout = sys.stdout
     self.output = io.StringIO()
     sys.stdout = self.output
     self.port = 25
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:7,代码来源:test_smtplib.py

示例3: test_debuglevel

 def test_debuglevel(self):
     mock_socket.reply_with(b"220 Hello world")
     smtp = smtplib.SMTP()
     smtp.set_debuglevel(1)
     with support.captured_stderr() as stderr:
         smtp.connect(HOST, self.port)
     smtp.close()
     expected = re.compile(r"^connect:", re.MULTILINE)
     self.assertRegex(stderr.getvalue(), expected)
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:9,代码来源:test_smtplib.py

示例4: testTimeoutNone

 def testTimeoutNone(self):
     mock_socket.reply_with(b"220 Hola mundo")
     self.assertIsNone(socket.getdefaulttimeout())
     socket.setdefaulttimeout(30)
     try:
         smtp = smtplib.SMTP(HOST, self.port, timeout=None)
     finally:
         socket.setdefaulttimeout(None)
     self.assertIsNone(smtp.sock.gettimeout())
     smtp.close()
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:10,代码来源:test_smtplib.py

示例5: testTimeoutDefault

 def testTimeoutDefault(self):
     mock_socket.reply_with(b"220 Hola mundo")
     self.assertIsNone(mock_socket.getdefaulttimeout())
     mock_socket.setdefaulttimeout(30)
     self.assertEqual(mock_socket.getdefaulttimeout(), 30)
     try:
         smtp = smtplib.SMTP(HOST, self.port)
     finally:
         mock_socket.setdefaulttimeout(None)
     self.assertEqual(smtp.sock.gettimeout(), 30)
     smtp.close()
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:11,代码来源:test_smtplib.py

示例6: testLocalHostName

 def testLocalHostName(self):
     mock_socket.reply_with(b"220 Hola mundo")
     # check that supplied local_hostname is used
     smtp = smtplib.SMTP(HOST, self.port, local_hostname="testhost")
     self.assertEqual(smtp.local_hostname, "testhost")
     smtp.close()
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:6,代码来源:test_smtplib.py

示例7: testBasic2

 def testBasic2(self):
     mock_socket.reply_with(b"220 Hola mundo")
     # connects, include port in host name
     smtp = smtplib.SMTP("%s:%s" % (HOST, self.port))
     smtp.close()
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:5,代码来源:test_smtplib.py

示例8: testBasic1

 def testBasic1(self):
     mock_socket.reply_with(b"220 Hola mundo")
     # connects
     smtp = smtplib.SMTP(HOST, self.port)
     smtp.close()
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:5,代码来源:test_smtplib.py

示例9: testTimeoutValue

 def testTimeoutValue(self):
     mock_socket.reply_with(b"220 Hola mundo")
     smtp = smtplib.SMTP(HOST, self.port, timeout=30)
     self.assertEqual(smtp.sock.gettimeout(), 30)
     smtp.close()
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:5,代码来源:test_smtplib.py


注:本文中的test.mock_socket.reply_with函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。