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


Python test_support.requires方法代码示例

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


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

示例1: test_write_full

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_write_full(self):
        devfull = '/dev/full'
        if not (os.path.exists(devfull) and
                stat.S_ISCHR(os.stat(devfull).st_mode)):
            # Issue #21934: OpenBSD does not have a /dev/full character device
            self.skipTest('requires %r' % devfull)
        with open(devfull, 'wb', 1) as f:
            with self.assertRaises(IOError):
                f.write('hello\n')
        with open(devfull, 'wb', 1) as f:
            with self.assertRaises(IOError):
                # Issue #17976
                f.write('hello')
                f.write('\n')
        with open(devfull, 'wb', 0) as f:
            with self.assertRaises(IOError):
                f.write('h') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_file2k.py

示例2: testPasswordProtectedSite

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def testPasswordProtectedSite(self):
        test_support.requires('network')
        with test_support.transient_internet('mueblesmoraleda.com'):
            url = 'http://mueblesmoraleda.com'
            robots_url = url + "/robots.txt"
            # First check the URL is usable for our purposes, since the
            # test site is a bit flaky.
            try:
                urlopen(robots_url)
            except HTTPError as e:
                if e.code not in {401, 403}:
                    self.skipTest(
                        "%r should return a 401 or 403 HTTP error, not %r"
                        % (robots_url, e.code))
            else:
                self.skipTest(
                    "%r should return a 401 or 403 HTTP error, not succeed"
                    % (robots_url))
            parser = robotparser.RobotFileParser()
            parser.set_url(url)
            try:
                parser.read()
            except IOError:
                self.skipTest('%s is unavailable' % url)
            self.assertEqual(parser.can_fetch("*", robots_url), False) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:27,代码来源:test_robotparser.py

示例3: setUpClass

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def setUpClass(cls):
##        requires('gui')
##        cls.root = Tk()
##        cls.text = Text(master=cls.root)
        cls.text = mockText()
        test_text = (
            'First line\n'
            'Line with target\n'
            'Last line\n')
        cls.text.insert('1.0', test_text)
        cls.pat = re.compile('target')

        cls.engine = se.SearchEngine(None)
        cls.engine.search_forward = lambda *args: ('f', args)
        cls.engine.search_backward = lambda *args: ('b', args)

##    @classmethod
##    def tearDownClass(cls):
##        cls.root.destroy()
##        del cls.root 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:22,代码来源:test_searchengine.py

示例4: test_basic

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_basic():
    test_support.requires('network')

    import urllib

    socket.RAND_status()
    try:
        socket.RAND_egd(1)
    except TypeError:
        pass
    else:
        print "didn't raise TypeError"
    socket.RAND_add("this is a random string", 75.0)

    f = urllib.urlopen('https://sf.net')
    buf = f.read()
    f.close() 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:19,代码来源:test_socket_ssl.py

示例5: test_large_file_ops

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
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':
            support.requires(
                'largefile',
                'test requires %s bytes and a long time to run' % self.LARGE)
        with self.open(support.TESTFN, "w+b", 0) as f:
            self.large_file_ops(f)
        with self.open(support.TESTFN, "w+b") as f:
            self.large_file_ops(f) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_io.py

示例6: test_unbounded_file

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_unbounded_file(self):
        # Issue #1174606: reading from an unbounded stream such as /dev/zero.
        zero = "/dev/zero"
        if not os.path.exists(zero):
            self.skipTest("{0} does not exist".format(zero))
        if sys.maxsize > 0x7FFFFFFF:
            self.skipTest("test can only run in a 32-bit address space")
        if support.real_max_memuse < support._2G:
            self.skipTest("test requires at least 2GB of memory")
        with self.open(zero, "rb", buffering=0) as f:
            self.assertRaises(OverflowError, f.read)
        with self.open(zero, "rb") as f:
            self.assertRaises(OverflowError, f.read)
        with self.open(zero, "r") as f:
            self.assertRaises(OverflowError, f.read) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_io.py

示例7: setUp

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def setUp(self):
        self.assertTrue(self.python)
        self.assertTrue(self.module)
        self.assertTrue(self.error)
        test_support.requires("xpickle")
        if not have_python_version(self.python):
            self.skipTest('%s not available' % self.python) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_xpickle.py

示例8: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_main():
    test_support.requires("network")
    test_support.run_unittest(AuthTests,
                              OtherNetworkTests,
                              CloseSocketTest,
                              TimeoutTest,
                              ) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_urllib2net.py

示例9: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_main():
    test_support.requires('network')
    with test_support.check_py3k_warnings(
            ("urllib.urlopen.. has been removed", DeprecationWarning)):
        test_support.run_unittest(URLTimeoutTest,
                                  urlopenNetworkTests,
                                  urlretrieveNetworkTests,
                                  urlopen_HttpsTests,
                                  urlopen_FTPTest) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_urllibnet.py

示例10: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_main():
    # We will NOT depend on the network resource flag
    # (Lib/test/regrtest.py -u network) since all tests here are only
    # localhost.  However, if this is a bad rationale, then uncomment
    # the next line.
    #test_support.requires("network")

    test_support.run_unittest(BasicAuthTests, ProxyAuthTests, TestUrlopen) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_urllib2_localnet.py

示例11: test_very_long_line

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_very_long_line(self, size):
        # Issue #22526
        requires('largefile')
        with open(TESTFN, "wb") as fp:
            fp.seek(size - 1)
            fp.write("\0")
        with open(TESTFN, "rb") as fp:
            for l in fp:
                pass
        self.assertEqual(len(l), size)
        self.assertEqual(l.count("\0"), size)
        l = None 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_file2k.py

示例12: test_networked

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_networked(self):
        # Default settings: requires a valid cert from a trusted CA
        import ssl
        test_support.requires('network')
        with test_support.transient_internet('self-signed.pythontest.net'):
            h = httplib.HTTPSConnection('self-signed.pythontest.net', 443)
            with self.assertRaises(ssl.SSLError) as exc_info:
                h.request('GET', '/')
            self.assertEqual(exc_info.exception.reason, 'CERTIFICATE_VERIFY_FAILED') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_httplib.py

示例13: test_networked_noverification

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_networked_noverification(self):
        # Switch off cert verification
        import ssl
        test_support.requires('network')
        with test_support.transient_internet('self-signed.pythontest.net'):
            context = ssl._create_stdlib_context()
            h = httplib.HTTPSConnection('self-signed.pythontest.net', 443,
                                        context=context)
            h.request('GET', '/')
            resp = h.getresponse()
            self.assertIn('nginx', resp.getheader('server')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_httplib.py

示例14: test_networked_good_cert

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_networked_good_cert(self):
        # We feed the server's cert as a validating cert
        import ssl
        test_support.requires('network')
        with test_support.transient_internet('self-signed.pythontest.net'):
            context = ssl.SSLContext(ssl.PROTOCOL_TLS)
            context.verify_mode = ssl.CERT_REQUIRED
            context.load_verify_locations(CERT_selfsigned_pythontestdotnet)
            h = httplib.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
            h.request('GET', '/')
            resp = h.getresponse()
            server_string = resp.getheader('server')
            self.assertIn('nginx', server_string) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_httplib.py

示例15: test_networked_bad_cert

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import requires [as 别名]
def test_networked_bad_cert(self):
        # We feed a "CA" cert that is unrelated to the server's cert
        import ssl
        test_support.requires('network')
        with test_support.transient_internet('self-signed.pythontest.net'):
            context = ssl.SSLContext(ssl.PROTOCOL_TLS)
            context.verify_mode = ssl.CERT_REQUIRED
            context.load_verify_locations(CERT_localhost)
            h = httplib.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
            with self.assertRaises(ssl.SSLError) as exc_info:
                h.request('GET', '/')
            self.assertEqual(exc_info.exception.reason, 'CERTIFICATE_VERIFY_FAILED') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_httplib.py


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