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


Python support.requires函数代码示例

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


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

示例1: setUpModule

def setUpModule():
    try:
        import signal
        # The default handler for SIGXFSZ is to abort the process.
        # By ignoring it, system calls exceeding the file size resource
        # limit will raise OSError instead of crashing the interpreter.
        signal.signal(signal.SIGXFSZ, signal.SIG_IGN)
    except (ImportError, AttributeError):
        pass

    # On Windows and Mac OSX this test consumes large resources; It
    # takes a long time to build the >2 GiB file and takes >2 GiB of disk
    # space therefore the resource must be enabled to run this test.
    # If not, nothing after this line stanza will be executed.
    if sys.platform[:3] == 'win' or sys.platform == 'darwin':
        requires('largefile',
                 'test requires %s bytes and a long time to run' % str(size))
    else:
        # Only run if the current filesystem supports large files.
        # (Skip this test on Windows, since we now always support
        # large files.)
        f = open(TESTFN, 'wb', buffering=0)
        try:
            # 2**31 == 2147483648
            f.seek(2147483649)
            # Seeking is not enough of a test: you must write and flush, too!
            f.write(b'x')
            f.flush()
        except (OSError, OverflowError):
            raise unittest.SkipTest("filesystem does not have "
                                    "largefile support")
        finally:
            f.close()
            unlink(TESTFN)
开发者ID:1st1,项目名称:cpython,代码行数:34,代码来源:test_largefile.py

示例2: setUpClass

 def setUpClass(cls):
     requires('gui')
     cls.root = Tk()
     cls.TV = TV = tv.TextViewer
     TV.transient = Func()
     TV.grab_set = Func()
     TV.wait_window = Func()
开发者ID:harveyqing,项目名称:read_cPython_source,代码行数:7,代码来源:test_textview.py

示例3: test_main

def test_main():
    support.requires('network')
    support.run_unittest(
        CreationTestCase,
        TCPTimeoutTestCase,
        UDPTimeoutTestCase,
    )
开发者ID:5outh,项目名称:Databases-Fall2014,代码行数:7,代码来源:test_timeout.py

示例4: setUpClass

 def setUpClass(cls):
     requires('gui')
     cls.root = Tk()
     cls.root.withdraw()
     editor = Editor(root=cls.root)
     cls.text = editor.text.text  # Test code does not need the wrapper.
     cls.formatter = pg.FormatParagraph(editor).format_paragraph_event
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:7,代码来源:test_paragraph.py

示例5: test_main

def test_main():
    support.requires('network')
    with support.check_py3k_warnings(
            ("urllib.urlopen.. has been removed", DeprecationWarning)):
        support.run_unittest(URLTimeoutTest,
                                  urlopenNetworkTests,
                                  urlretrieveNetworkTests)
开发者ID:isaiah,项目名称:jython3,代码行数:7,代码来源:test_urllibnet.py

示例6: test_bad_address

    def test_bad_address(self):
        # Make sure proper exception is raised when connecting to a bogus
        # address.

        # as indicated by the comment below, this might fail with some ISP,
        # so we run the test only when -unetwork/-uall is specified to
        # mitigate the problem a bit (see #17564)
        support.requires('network')
        self.assertRaises(OSError,
                          # Given that both VeriSign and various ISPs have in
                          # the past or are presently hijacking various invalid
                          # domain name requests in an attempt to boost traffic
                          # to their own sites, finding a domain name to use
                          # for this test is difficult.  RFC2606 leads one to
                          # believe that '.invalid' should work, but experience
                          # seemed to indicate otherwise.  Single character
                          # TLDs are likely to remain invalid, so this seems to
                          # be the best choice. The trailing '.' prevents a
                          # related problem: The normal DNS resolver appends
                          # the domain names from the search path if there is
                          # no '.' the end and, and if one of those domains
                          # implements a '*' rule a result is returned.
                          # However, none of this will prevent the test from
                          # failing if the ISP hijacks all invalid domain
                          # requests.  The real solution would be to be able to
                          # parameterize the framework with a mock resolver.
                          urllib.request.urlopen,
                          "http://sadflkjsasf.i.nvali.d./")
开发者ID:MaximVanyushkin,项目名称:Sharp.RemoteQueryable,代码行数:28,代码来源:test_urllib2_localnet.py

示例7: testPasswordProtectedSite

 def testPasswordProtectedSite(self):
     support.requires('network')
     with 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 = urllib.robotparser.RobotFileParser()
         parser.set_url(url)
         try:
             parser.read()
         except URLError:
             self.skipTest('%s is unavailable' % url)
         self.assertEqual(parser.can_fetch("*", robots_url), False)
开发者ID:AlexHorlenko,项目名称:ironpython3,代码行数:25,代码来源:test_robotparser.py

示例8: test_main

def test_main():
    support.requires("network")
    support.run_unittest(AuthTests,
                              OtherNetworkTests,
                              CloseSocketTest,
                              TimeoutTest,
                              )
开发者ID:LinkedModernismProject,项目名称:web_code,代码行数:7,代码来源:test_urllib2net.py

示例9: setUpClass

 def setUpClass(cls):
     requires('gui')
     cls.root = Tk()
     cls.root.withdraw()
     keylist = [['<Key-F12>'], ['<Control-Key-x>', '<Control-Key-X>']]
     cls.dialog = cls.Validator(
         cls.root, 'Title', '<<Test>>', keylist, _utest=True)
开发者ID:1st1,项目名称:cpython,代码行数:7,代码来源:test_config_key.py

示例10: test_networked

 def test_networked(self):
     # Default settings: no cert verification is done
     support.requires("network")
     with support.transient_internet("svn.python.org"):
         h = client.HTTPSConnection("svn.python.org", 443)
         h.request("GET", "/")
         resp = h.getresponse()
         self._check_svn_python_org(resp)
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:8,代码来源:test_httplib.py

示例11: setUpClass

 def setUpClass(cls):
     requires('gui')
     cls.root = tk.Tk()
     cls.root.withdraw()
     def cmd(tkpath, func):
         assert isinstance(tkpath, str)
         assert isinstance(func, type(cmd))
     cls.root.createcommand = cmd
开发者ID:1st1,项目名称:cpython,代码行数:8,代码来源:test_macosx.py

示例12: setUpClass

 def setUpClass(cls):
     if 'tkinter' in str(Text):
         requires('gui')
         cls.tk = Tk()
         cls.text = Text(cls.tk)
     else:
         cls.text = Text()
     cls.auto_expand = AutoExpand(Dummy_Editwin(cls.text))
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:8,代码来源:test_autoexpand.py

示例13: testPythonOrg

 def testPythonOrg(self):
     support.requires('network')
     with support.transient_internet('www.python.org'):
         parser = urllib.robotparser.RobotFileParser(
             "http://www.python.org/robots.txt")
         parser.read()
         self.assertTrue(
             parser.can_fetch("*", "http://www.python.org/robots.txt"))
开发者ID:AlexHorlenko,项目名称:ironpython3,代码行数:8,代码来源:test_robotparser.py

示例14: test_networked

 def test_networked(self):
     # Default settings: requires a valid cert from a trusted CA
     import ssl
     support.requires('network')
     with support.transient_internet('self-signed.pythontest.net'):
         h = client.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:chidea,项目名称:GoPythonDLLWrapper,代码行数:9,代码来源:test_httplib.py

示例15: test_networked_trusted_by_default_cert

 def test_networked_trusted_by_default_cert(self):
     # Default settings: requires a valid cert from a trusted CA
     support.requires('network')
     with support.transient_internet('www.python.org'):
         h = client.HTTPSConnection('www.python.org', 443)
         h.request('GET', '/')
         resp = h.getresponse()
         content_type = resp.getheader('content-type')
         self.assertIn('text/html', content_type)
开发者ID:Bachmann1234,项目名称:python-emoji,代码行数:9,代码来源:test_httplib.py


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