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


Python support.get_attribute函数代码示例

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


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

示例1: test_connect_using_sslcontext_verified

 def test_connect_using_sslcontext_verified(self):
     support.get_attribute(smtplib, 'SMTP_SSL')
     context = ssl.create_default_context()
     with support.transient_internet(self.testServer):
         server = smtplib.SMTP_SSL(self.testServer, self.remotePort, context=context)
         server.ehlo()
         server.quit()
开发者ID:LesyaMazurevich,项目名称:python-1,代码行数:7,代码来源:test_smtpnet.py

示例2: test_connect_using_sslcontext

 def test_connect_using_sslcontext(self):
     context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
     support.get_attribute(smtplib, 'SMTP_SSL')
     with support.transient_internet(self.testServer):
         server = smtplib.SMTP_SSL(self.testServer, self.remotePort, context=context)
         server.ehlo()
         server.quit()
开发者ID:10sr,项目名称:cpython,代码行数:7,代码来源:test_smtpnet.py

示例3: test_connect_using_sslcontext

 def test_connect_using_sslcontext(self):
     context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
     context.check_hostname = False
     context.verify_mode = ssl.CERT_NONE
     support.get_attribute(smtplib, 'SMTP_SSL')
     with support.transient_internet(self.testServer):
         server = smtplib.SMTP_SSL(self.testServer, self.remotePort, context=context)
         server.ehlo()
         server.quit()
开发者ID:1st1,项目名称:cpython,代码行数:9,代码来源:test_smtpnet.py

示例4: test_connect_using_sslcontext_verified

    def test_connect_using_sslcontext_verified(self):
        with support.transient_internet(self.testServer):
            can_verify = check_ssl_verifiy(self.testServer, self.remotePort)
            if not can_verify:
                self.skipTest("SSL certificate can't be verified")

        support.get_attribute(smtplib, 'SMTP_SSL')
        context = ssl.create_default_context()
        with support.transient_internet(self.testServer):
            server = smtplib.SMTP_SSL(self.testServer, self.remotePort, context=context)
            server.ehlo()
            server.quit()
开发者ID:10sr,项目名称:cpython,代码行数:12,代码来源:test_smtpnet.py

示例5: test_connect_starttls

 def test_connect_starttls(self):
     support.get_attribute(smtplib, "SMTP_SSL")
     with support.transient_internet(self.testServer):
         server = smtplib.SMTP(self.testServer, self.remotePort)
         try:
             server.starttls(context=self.context)
         except smtplib.SMTPException as e:
             if e.args[0] == "STARTTLS extension not supported by server.":
                 unittest.skip(e.args[0])
             else:
                 raise
         server.ehlo()
         server.quit()
开发者ID:mshmoustafa,项目名称:static-python,代码行数:13,代码来源:test_smtpnet.py

示例6: test_refleaks_in___init__

 def test_refleaks_in___init__(self):
     gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount')
     bzd = BZ2Decompressor()
     refs_before = gettotalrefcount()
     for i in range(100):
         bzd.__init__()
     self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:7,代码来源:test_bz2.py

示例7: test_connect_starttls

 def test_connect_starttls(self):
     support.get_attribute(smtplib, 'SMTP_SSL')
     context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
     context.check_hostname = False
     context.verify_mode = ssl.CERT_NONE
     with support.transient_internet(self.testServer):
         server = smtplib.SMTP(self.testServer, self.remotePort)
         try:
             server.starttls(context=context)
         except smtplib.SMTPException as e:
             if e.args[0] == 'STARTTLS extension not supported by server.':
                 unittest.skip(e.args[0])
             else:
                 raise
         server.ehlo()
         server.quit()
开发者ID:1st1,项目名称:cpython,代码行数:16,代码来源:test_smtpnet.py

示例8: test_refleaks_in_hash___init__

 def test_refleaks_in_hash___init__(self):
     gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount')
     sha1_hash = c_hashlib.new('sha1')
     refs_before = gettotalrefcount()
     for i in range(100):
         sha1_hash.__init__('sha1')
     self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
开发者ID:CCNITSilchar,项目名称:cpython,代码行数:7,代码来源:test_hashlib.py

示例9: test_issue31315

 def test_issue31315(self):
     # There shouldn't be an assertion failure in imp.create_dynamic(),
     # when spec.name is not a string.
     create_dynamic = support.get_attribute(imp, 'create_dynamic')
     class BadSpec:
         name = None
         origin = 'foo'
     with self.assertRaises(TypeError):
         create_dynamic(BadSpec())
开发者ID:ndorte,项目名称:cpython,代码行数:9,代码来源:test_imp.py

示例10: test_interrupted_write

    def test_interrupted_write(self):
        # BaseHandler._write() and _flush() have to write all data, even if
        # it takes multiple send() calls.  Test this by interrupting a send()
        # call with a Unix signal.
        threading = support.import_module("threading")
        pthread_kill = support.get_attribute(signal, "pthread_kill")

        def app(environ, start_response):
            start_response("200 OK", [])
            return [b'\0' * support.SOCK_MAX_SIZE]

        class WsgiHandler(NoLogRequestHandler, WSGIRequestHandler):
            pass

        server = make_server(support.HOST, 0, app, handler_class=WsgiHandler)
        self.addCleanup(server.server_close)
        interrupted = threading.Event()

        def signal_handler(signum, frame):
            interrupted.set()

        original = signal.signal(signal.SIGUSR1, signal_handler)
        self.addCleanup(signal.signal, signal.SIGUSR1, original)
        received = None
        main_thread = threading.get_ident()

        def run_client():
            http = HTTPConnection(*server.server_address)
            http.request("GET", "/")
            with http.getresponse() as response:
                response.read(100)
                # The main thread should now be blocking in a send() system
                # call.  But in theory, it could get interrupted by other
                # signals, and then retried.  So keep sending the signal in a
                # loop, in case an earlier signal happens to be delivered at
                # an inconvenient moment.
                while True:
                    pthread_kill(main_thread, signal.SIGUSR1)
                    if interrupted.wait(timeout=float(1)):
                        break
                nonlocal received
                received = len(response.read())
            http.close()

        background = threading.Thread(target=run_client)
        background.start()
        server.handle_request()
        background.join()
        self.assertEqual(received, support.SOCK_MAX_SIZE - 100)
开发者ID:3lnc,项目名称:cpython,代码行数:49,代码来源:test_wsgiref.py

示例11: test_symlink

 def test_symlink(self):
     # Issue 7880
     symlink = get_attribute(os, "symlink")
     def get(python):
         cmd = [python, '-c',
                'import sysconfig; print sysconfig.get_platform()']
         p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
         return p.communicate()
     real = os.path.realpath(sys.executable)
     link = os.path.abspath(TESTFN)
     symlink(real, link)
     try:
         self.assertEqual(get(real), get(link))
     finally:
         unlink(link)
开发者ID:isaiah,项目名称:jython3,代码行数:15,代码来源:test_sysconfig.py

示例12: file

# Ridiculously simple test of the os.startfile function for Windows.
#
# empty.vbs is an empty file (except for a comment), which does
# nothing when run with cscript or wscript.
#
# A possible improvement would be to have empty.vbs do something that
# we can detect here, to make sure that not only the os.startfile()
# call succeeded, but also the script actually has run.

import unittest
from test import support
import os
import sys
from os import path

startfile = support.get_attribute(os, 'startfile')


class TestCase(unittest.TestCase):
    def test_nonexisting(self):
        self.assertRaises(OSError, startfile, "nonexisting.vbs")

    def test_empty(self):
        # We need to make sure the child process starts in a directory
        # we're not about to delete. If we're running under -j, that
        # means the test harness provided directory isn't a safe option.
        # See http://bugs.python.org/issue15526 for more details
        with support.change_cwd(path.dirname(sys.executable)):
            empty = path.join(path.dirname(__file__), "empty.vbs")
            startfile(empty)
            startfile(empty, "open")
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:31,代码来源:test_startfile.py

示例13: test_connect

 def test_connect(self):
     support.get_attribute(smtplib, 'SMTP_SSL')
     server = smtplib.SMTP_SSL(self.testServer, self.remotePort)
     server.ehlo()
     server.quit()
开发者ID:Kanma,项目名称:Athena-Dependencies-Python,代码行数:5,代码来源:test_smtpnet.py

示例14: fork

"""This test checks for correct fork() behavior.
"""

import imp
import os
import signal
import sys
import time

from test.fork_wait import ForkWait
from test.support import run_unittest, reap_children, get_attribute, import_module
threading = import_module('threading')

# Skip test if fork does not exist.
get_attribute(os, 'fork')


class ForkTest(ForkWait):
    def wait_impl(self, cpid):
        for i in range(10):
            # waitpid() shouldn't hang, but some of the buildbots seem to hang
            # in the forking tests.  This is an attempt to fix the problem.
            spid, status = os.waitpid(cpid, os.WNOHANG)
            if spid == cpid:
                break
            time.sleep(1.0)

        self.assertEqual(spid, cpid)
        self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))

    def test_import_lock_fork(self):
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:31,代码来源:test_fork1.py

示例15: test_get_attribute

 def test_get_attribute(self):
     self.assertEqual(support.get_attribute(self, "test_get_attribute"),
                     self.test_get_attribute)
     self.assertRaises(unittest.SkipTest, support.get_attribute, self, "foo")
     with self.assertRaisesRegexp(unittest.SkipTest, 'unittest'):
         support.get_attribute(unittest, 'foo')
     with self.assertRaisesRegexp(unittest.SkipTest, 'ClassicClass'):
         support.get_attribute(ClassicClass, 'foo')
     with self.assertRaisesRegexp(unittest.SkipTest, 'ClassicClass'):
         support.get_attribute(ClassicClass(), 'foo')
     with self.assertRaisesRegexp(unittest.SkipTest, 'NewStyleClass'):
         support.get_attribute(NewStyleClass, 'foo')
     with self.assertRaisesRegexp(unittest.SkipTest, 'NewStyleClass'):
         support.get_attribute(NewStyleClass(), 'foo')
开发者ID:RDWang,项目名称:python,代码行数:14,代码来源:test_test_support.py


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