• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python support.is_resource_enabled函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_main

def test_main(verbose=False):
    if skip_expected:
        raise unittest.SkipTest("No SSL support")

    global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT
    CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
                            "keycert.pem")
    SVN_PYTHON_ORG_ROOT_CERT = os.path.join(
        os.path.dirname(__file__) or os.curdir,
        "https_svn_python_org_root.pem")

    if (not os.path.exists(CERTFILE) or
        not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)):
        raise support.TestFailed("Can't read certificate files!")

    tests = [BasicTests]

    if support.is_resource_enabled('network'):
        tests.append(NetworkedTests)

    if _have_threads:
        thread_info = support.threading_setup()
        if thread_info and support.is_resource_enabled('network'):
            tests.append(ThreadedTests)

    support.run_unittest(*tests)

    if _have_threads:
        support.threading_cleanup(*thread_info)
开发者ID:Kanma,项目名称:Athena-Dependencies-Python,代码行数:29,代码来源:test_ssl.py


示例2: test_random_files

    def test_random_files(self):
        # Test roundtrip on random python modules.
        # pass the '-ucpu' option to process the full directory.

        import glob, random
        fn = support.findfile("tokenize_tests.txt")
        tempdir = os.path.dirname(fn) or os.curdir
        testfiles = glob.glob(os.path.join(tempdir, "test*.py"))

        # Tokenize is broken on test_pep3131.py because regular expressions are
        # broken on the obscure unicode identifiers in it. *sigh*
        # With roundtrip extended to test the 5-tuple mode of  untokenize,
        # 7 more testfiles fail.  Remove them also until the failure is diagnosed.

        testfiles.remove(os.path.join(tempdir, "test_pep3131.py"))
        for f in ('buffer', 'builtin', 'fileio', 'inspect', 'os', 'platform', 'sys'):
            testfiles.remove(os.path.join(tempdir, "test_%s.py") % f)

        if not support.is_resource_enabled("cpu"):
            testfiles = random.sample(testfiles, 10)

        for testfile in testfiles:
            with open(testfile, 'rb') as f:
                with self.subTest(file=testfile):
                    self.check_roundtrip(f)
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:25,代码来源:test_tokenize.py


示例3: test_main

def test_main():
    tests = [
                ChdirTestCase,
                ImportTestCase,
                ImportPackageTestCase,
                ZipimportTestCase,
                PyCompileTestCase,
                ExecfileTestCase,
                ExecfileTracebackTestCase,
                ListdirTestCase,
                DirsTestCase,
                FilesTestCase,
                SymlinkTestCase
            ]
    if WINDOWS:
        tests.append(WindowsChdirTestCase)
        tests.remove(SymlinkTestCase)       #  os.symlink ... Availability: Unix.

    if support.is_jython:
        tests.extend((ImportJavaClassTestCase,
                      ImportJarTestCase))
 
    if support.is_resource_enabled('subprocess'):
        tests.append(SubprocessTestCase)

    support.run_unittest(*tests)
开发者ID:isaiah,项目名称:jython3,代码行数:26,代码来源:test_chdir.py


示例4: testPythonOrg

 def testPythonOrg(self):
     if not support.is_resource_enabled('network'):
         return
     parser = urllib.robotparser.RobotFileParser(
         "http://www.python.org/robots.txt")
     parser.read()
     self.assertTrue(parser.can_fetch("*",
                                      "http://www.python.org/robots.txt"))
开发者ID:Kanma,项目名称:Athena-Dependencies-Python,代码行数:8,代码来源:test_robotparser.py


示例5: testPasswordProtectedSite

 def testPasswordProtectedSite(self):
     if not support.is_resource_enabled('network'):
         return
     # whole site is password-protected.
     url = 'http://mueblesmoraleda.com'
     parser = urllib.robotparser.RobotFileParser()
     parser.set_url(url)
     parser.read()
     self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
开发者ID:Kanma,项目名称:Athena-Dependencies-Python,代码行数:9,代码来源:test_robotparser.py


示例6: test_main

def test_main():
    tests = [TestImaplib]

    if support.is_resource_enabled('network'):
        if ssl:
            global CERTFILE
            CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
                                    "keycert.pem")
            if not os.path.exists(CERTFILE):
                raise support.TestFailed("Can't read certificate files!")
        tests.extend([
            ThreadedNetworkedTests, ThreadedNetworkedTestsSSL,
            RemoteIMAPTest, RemoteIMAP_SSLTest, RemoteIMAP_STARTTLSTest,
        ])

    support.run_unittest(*tests)
开发者ID:Naddiseo,项目名称:cpython,代码行数:16,代码来源:test_imaplib.py


示例7: load_tests

def load_tests(*args):
    tests = [TestImaplib]

    if support.is_resource_enabled('network'):
        if ssl:
            global CERTFILE
            CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
                                    "keycert.pem")
            if not os.path.exists(CERTFILE):
                raise support.TestFailed("Can't read certificate files!")
        tests.extend([
            ThreadedNetworkedTests, ThreadedNetworkedTestsSSL,
            RemoteIMAPTest, RemoteIMAP_SSLTest, RemoteIMAP_STARTTLSTest,
        ])

    return unittest.TestSuite([unittest.makeSuite(test) for test in tests])
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:16,代码来源:test_imaplib.py


示例8: test_no_leaking

 def test_no_leaking(self):
     # Make sure we leak no resources
     if (not hasattr(support, "is_resource_enabled") or
         support.is_resource_enabled("subprocess") and not mswindows):
         max_handles = 1026 # too much for most UNIX systems
     else:
         max_handles = 65
     for i in range(max_handles):
         p = subprocess.Popen([sys.executable, "-c",
                               "import sys;"
                               "sys.stdout.write(sys.stdin.read())"],
                              stdin=subprocess.PIPE,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
         data = p.communicate(b"lime")[0]
         self.assertEqual(data, b"lime")
开发者ID:LinkedModernismProject,项目名称:web_code,代码行数:16,代码来源:test_subprocess.py


示例9: test_main

def test_main():
    if not support.is_resource_enabled("xpickle"):
        print("test_xpickle -- skipping backwards compat tests.", file=sys.stderr)
        print("Use 'regrtest.py -u xpickle' to run them.", file=sys.stderr)
        sys.stderr.flush()

    support.run_unittest(
        DumpCPickle_LoadPickle,
        DumpPickle_LoadCPickle,
        CPicklePython24Compat,
        CPicklePython25Compat,
        CPicklePython26Compat,
        PicklePython24Compat,
        PicklePython25Compat,
        PicklePython26Compat,
    )
开发者ID:isaiah,项目名称:jython3,代码行数:16,代码来源:test_xpickle.py


示例10: test_large_file_ops

 def test_large_file_ops(self):
     # On Windows and Mac OSX this test comsumes large resources; It takes
     # a long time to build the >2GB file and takes >2GB of disk space
     # therefore the resource must be enabled to run this test.
     if sys.platform[:3] == 'win' or sys.platform == 'darwin':
         if not support.is_resource_enabled("largefile"):
             print("\nTesting large file ops skipped on %s." % sys.platform,
                   file=sys.stderr)
             print("It requires %d bytes and a long time." % self.LARGE,
                   file=sys.stderr)
             print("Use 'regrtest.py -u largefile test_io' to run it.",
                   file=sys.stderr)
             return
     f = io.open(support.TESTFN, "w+b", 0)
     self.large_file_ops(f)
     f.close()
     f = io.open(support.TESTFN, "w+b")
     self.large_file_ops(f)
     f.close()
开发者ID:LinkedModernismProject,项目名称:web_code,代码行数:19,代码来源:test_io.py


示例11: testSSLconnect

    def testSSLconnect(self):
        if not support.is_resource_enabled('network'):
            return
        s = ssl.wrap_socket(socket.socket(socket.AF_INET),
                            cert_reqs=ssl.CERT_NONE)
        s.connect(("svn.python.org", 443))
        c = s.getpeercert()
        if c:
            raise support.TestFailed("Peer cert %s shouldn't be here!")
        s.close()

        # this should fail because we have no verification certs
        s = ssl.wrap_socket(socket.socket(socket.AF_INET),
                            cert_reqs=ssl.CERT_REQUIRED)
        try:
            s.connect(("svn.python.org", 443))
        except ssl.SSLError:
            pass
        finally:
            s.close()
开发者ID:Kanma,项目名称:Athena-Dependencies-Python,代码行数:20,代码来源:test_ssl.py


示例12: RemoteIMAPTest

        with self.assertRaisesRegex(
                ssl.CertificateError,
                "hostname '127.0.0.1' doesn't match 'localhost'"):
            with self.reaped_server(SimpleIMAPHandler) as server:
                client = self.imap_class(*server.server_address,
                                         ssl_context=ssl_context)
                client.shutdown()

        with self.reaped_server(SimpleIMAPHandler) as server:
            client = self.imap_class("localhost", server.server_address[1],
                                     ssl_context=ssl_context)
            client.shutdown()


@unittest.skipUnless(
    support.is_resource_enabled('network'), 'network resource disabled')
class RemoteIMAPTest(unittest.TestCase):
    host = 'cyrus.andrew.cmu.edu'
    port = 143
    username = 'anonymous'
    password = 'pass'
    imap_class = imaplib.IMAP4

    def setUp(self):
        with transient_internet(self.host):
            self.server = self.imap_class(self.host, self.port)

    def tearDown(self):
        if self.server is not None:
            with transient_internet(self.host):
                self.server.logout()
开发者ID:ChanChiChoi,项目名称:cpython,代码行数:31,代码来源:test_imaplib.py


示例13: resolve_address

"""Unit tests for socket timeout feature."""

import functools
import unittest
from test import support

# This requires the 'network' resource as given on the regrtest command line.
skip_expected = not support.is_resource_enabled('network')

import time
import errno
import socket


@functools.lru_cache()
def resolve_address(host, port):
    """Resolve an (host, port) to an address.

    We must perform name resolution before timeout tests, otherwise it will be
    performed by connect().
    """
    with support.transient_internet(host):
        return socket.getaddrinfo(host, port, socket.AF_INET,
                                  socket.SOCK_STREAM)[0][4]


class CreationTestCase(unittest.TestCase):
    """Test case for socket.gettimeout() and socket.settimeout()"""

    def setUp(self):
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
开发者ID:5outh,项目名称:Databases-Fall2014,代码行数:31,代码来源:test_timeout.py


示例14: run_compat_test

def run_compat_test(python_name):
    return (support.is_resource_enabled("xpickle") and
            have_python_version(python_name))
开发者ID:isaiah,项目名称:jython3,代码行数:3,代码来源:test_xpickle.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python support.make_bad_fd函数代码示例发布时间:2022-05-27
下一篇:
Python support.import_module函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap