本文整理汇总了Python中aiosmtpd.controller.Controller.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.stop方法的具体用法?Python Controller.stop怎么用?Python Controller.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aiosmtpd.controller.Controller
的用法示例。
在下文中一共展示了Controller.stop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_real_mail_aiosmtpd
# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import stop [as 别名]
def test_real_mail_aiosmtpd(self):
""" Test sending messages with a real-world SMTPD server """
if aiosmtpd is None:
self.skipTest('aiosmtpd not available')
# Start an smtp server
mail_handler = StashingHandler()
controller = Controller(mail_handler, loop=None,
hostname='localhost', port=self.smtpd_port)
controller.start()
# Give it time to settle
sleep(0.5)
# Initialize a Postman
postman = Postman('[email protected]',
NoLoginSMTP('localhost', self.smtpd_port, None, None))
# Send messages
with postman.connect() as c:
# Send plaintext message
msg = Message(['[email protected]'], 'Subject', 'HTML message')
c.sendmail(msg)
# Send unicode message
msg = Message(['[email protected]'], u'Håkon', u'Håkon')
c.sendmail(msg)
# Done
controller.stop()
# Test
self.assertEqual(len(mail_handler.mail), 2)
示例2: test_server_attribute
# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import stop [as 别名]
def test_server_attribute(self):
controller = Controller(Sink())
self.assertIsNone(controller.server)
try:
controller.start()
self.assertIsNotNone(controller.server)
finally:
controller.stop()
self.assertIsNone(controller.server)
示例3: __init__
# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import stop [as 别名]
class CapturingAiosmtpdServer:
"""An async SMTP server / context manager for testing RPC effects."""
def __init__(self):
self.messages = []
self.handler = CapturingAiosmtpdHandler(context=self)
self.controller = Controller(
handler=self.handler, hostname="localhost", port=10025)
def __enter__(self):
self.controller.start()
return self
def __exit__(self, *exc):
self.controller.stop()