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


Python support.HOST属性代码示例

本文整理汇总了Python中test.support.HOST属性的典型用法代码示例。如果您正苦于以下问题:Python support.HOST属性的具体用法?Python support.HOST怎么用?Python support.HOST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在test.support的用法示例。


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

示例1: test_getsockaddrarg

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def test_getsockaddrarg(self):
        sock = socket.socket()
        self.addCleanup(sock.close)
        port = support.find_unused_port()
        big_port = port + 65536
        neg_port = port - 65536
        self.assertRaises(OverflowError, sock.bind, (HOST, big_port))
        self.assertRaises(OverflowError, sock.bind, (HOST, neg_port))
        # Since find_unused_port() is inherently subject to race conditions, we
        # call it a couple times if necessary.
        for i in itertools.count():
            port = support.find_unused_port()
            try:
                sock.bind((HOST, port))
            except OSError as e:
                if e.errno != errno.EADDRINUSE or i == 5:
                    raise
            else:
                break 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:test_socket.py

示例2: testSend

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def testSend(self):
        # connect and send mail
        m = 'A test message'
        smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
        smtp.sendmail('John', 'Sally', m)
        # XXX(nnorwitz): this test is flaky and dies with a bad file descriptor
        # in asyncore.  This sleep might help, but should really be fixed
        # properly by using an Event variable.
        time.sleep(0.01)
        smtp.quit()

        self.client_evt.set()
        self.serv_evt.wait()
        self.output.flush()
        mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END)
        self.assertEqual(self.output.getvalue(), mexpect) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_smtplib.py

示例3: testSendNullSender

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def testSendNullSender(self):
        m = 'A test message'
        smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
        smtp.sendmail('<>', 'Sally', m)
        # XXX (see comment in testSend)
        time.sleep(0.01)
        smtp.quit()

        self.client_evt.set()
        self.serv_evt.wait()
        self.output.flush()
        mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END)
        self.assertEqual(self.output.getvalue(), mexpect)
        debugout = smtpd.DEBUGSTREAM.getvalue()
        sender = re.compile("^sender: <>$", re.MULTILINE)
        self.assertRegex(debugout, sender) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_smtplib.py

示例4: testSendMessageWithSomeAddresses

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def testSendMessageWithSomeAddresses(self):
        # Make sure nothing breaks if not all of the three 'to' headers exist
        m = email.mime.text.MIMEText('A test message')
        m['From'] = 'foo@bar.com'
        m['To'] = 'John, Dinsdale'
        smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
        smtp.send_message(m)
        # XXX (see comment in testSend)
        time.sleep(0.01)
        smtp.quit()

        self.client_evt.set()
        self.serv_evt.wait()
        self.output.flush()
        # Add the X-Peer header that DebuggingServer adds
        m['X-Peer'] = socket.gethostbyname('localhost')
        mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
        self.assertEqual(self.output.getvalue(), mexpect)
        debugout = smtpd.DEBUGSTREAM.getvalue()
        sender = re.compile("^sender: foo@bar.com$", re.MULTILINE)
        self.assertRegex(debugout, sender)
        for addr in ('John', 'Dinsdale'):
            to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
                                 re.MULTILINE)
            self.assertRegex(debugout, to_addr) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:test_smtplib.py

示例5: testSendMessageMultipleResentRaises

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def testSendMessageMultipleResentRaises(self):
        m = email.mime.text.MIMEText('A test message')
        m['From'] = 'foo@bar.com'
        m['To'] = 'John'
        m['CC'] = 'Sally, Fred'
        m['Bcc'] = 'John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>'
        m['Resent-Date'] = 'Thu, 1 Jan 1970 17:42:00 +0000'
        m['Resent-From'] = 'holy@grail.net'
        m['Resent-To'] = 'Martha <my_mom@great.cooker.com>, Jeff'
        m['Resent-Bcc'] = 'doe@losthope.net'
        m['Resent-Date'] = 'Thu, 2 Jan 1970 17:42:00 +0000'
        m['Resent-To'] = 'holy@grail.net'
        m['Resent-From'] = 'Martha <my_mom@great.cooker.com>, Jeff'
        smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
        with self.assertRaises(ValueError):
            smtp.send_message(m)
        smtp.close() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:test_smtplib.py

示例6: setUp

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def setUp(self):
        self.real_getfqdn = socket.getfqdn
        socket.getfqdn = mock_socket.getfqdn
        self.serv_evt = threading.Event()
        self.client_evt = threading.Event()
        # Pick a random unused port by passing 0 for the port number
        self.serv = SimSMTPServer((HOST, 0), ('nowhere', -1), decode_data=True)
        # Keep a note of what port was assigned
        self.port = self.serv.socket.getsockname()[1]
        serv_args = (self.serv, self.serv_evt, self.client_evt)
        self.thread = threading.Thread(target=debugging_server, args=serv_args)
        self.thread.start()

        # wait until server thread has assigned a port number
        self.serv_evt.wait()
        self.serv_evt.clear() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_smtplib.py

示例7: testEHLO

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def testEHLO(self):
        smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)

        # no features should be present before the EHLO
        self.assertEqual(smtp.esmtp_features, {})

        # features expected from the test server
        expected_features = {'expn':'',
                             'size': '20000000',
                             'starttls': '',
                             'deliverby': '',
                             'help': '',
                             }

        smtp.ehlo()
        self.assertEqual(smtp.esmtp_features, expected_features)
        for k in expected_features:
            self.assertTrue(smtp.has_extn(k))
        self.assertFalse(smtp.has_extn('unsupported-feature'))
        smtp.quit() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:test_smtplib.py

示例8: test_HOST

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def test_HOST(self):
        s = socket.socket()
        s.bind((support.HOST, 0))
        s.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_test_support.py

示例9: test_find_unused_port

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def test_find_unused_port(self):
        port = support.find_unused_port()
        s = socket.socket()
        s.bind((support.HOST, port))
        s.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_test_support.py

示例10: setUp

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def setUp(self):
        self.server = HTTPServer((support.HOST, 0), RobotHandler)

        self.t = threading.Thread(
            name='HTTPServer serving',
            target=self.server.serve_forever,
            # Short poll interval to make the test finish quickly.
            # Time between requests is short enough that we won't wake
            # up spuriously too many times.
            kwargs={'poll_interval':0.01})
        self.t.daemon = True  # In case this function raises.
        self.t.start() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_robotparser.py

示例11: testPasswordProtectedSite

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def testPasswordProtectedSite(self):
        addr = self.server.server_address
        url = 'http://' + support.HOST + ':' + str(addr[1])
        robots_url = url + "/robots.txt"
        parser = robotparser.RobotFileParser()
        parser.set_url(url)
        parser.read()
        self.assertFalse(parser.can_fetch("*", robots_url)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_robotparser.py

示例12: clientSetUp

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def clientSetUp(self):
        self.cli = socket.socket(socket.PF_RDS, socket.SOCK_SEQPACKET, 0)
        try:
            # RDS sockets must be bound explicitly to send or receive data
            self.cli.bind((HOST, 0))
            self.cli_addr = self.cli.getsockname()
        except OSError:
            # skipTest should not be called here, and will be called in the
            # server instead
            pass 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:12,代码来源:test_socket.py

示例13: test_host_resolution

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def test_host_resolution(self):
        for addr in ['0.1.1.~1', '1+.1.1.1', '::1q', '::1::2',
                     '1:1:1:1:1:1:1:1:1']:
            self.assertRaises(OSError, socket.gethostbyname, addr)
            self.assertRaises(OSError, socket.gethostbyaddr, addr)

        for addr in [support.HOST, '10.0.0.1', '255.255.255.255']:
            self.assertEqual(socket.gethostbyname(addr), addr)

        # we don't test support.HOSTv6 because there's a chance it doesn't have
        # a matching name entry (e.g. 'ip6-localhost')
        for host in [support.HOST]:
            self.assertIn(host, socket.gethostbyaddr(host)[2]) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:test_socket.py

示例14: test_listen_backlog

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def test_listen_backlog(self):
        for backlog in 0, -1:
            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as srv:
                srv.bind((HOST, 0))
                srv.listen(backlog)

        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as srv:
            srv.bind((HOST, 0))
            srv.listen() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:11,代码来源:test_socket.py

示例15: _testSendAndRecv

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import HOST [as 别名]
def _testSendAndRecv(self):
        self.data = b'spam'
        self.cli.sendto(self.data, 0, (HOST, self.port)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:test_socket.py


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