當前位置: 首頁>>代碼示例>>Python>>正文


Python _testcapi.INT_MAX屬性代碼示例

本文整理匯總了Python中_testcapi.INT_MAX屬性的典型用法代碼示例。如果您正苦於以下問題:Python _testcapi.INT_MAX屬性的具體用法?Python _testcapi.INT_MAX怎麽用?Python _testcapi.INT_MAX使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在_testcapi的用法示例。


在下文中一共展示了_testcapi.INT_MAX屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_formatting_c_limits

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_formatting_c_limits(self):
        from _testcapi import PY_SSIZE_T_MAX, INT_MAX, UINT_MAX
        SIZE_MAX = (1 << (PY_SSIZE_T_MAX.bit_length() + 1)) - 1
        width = int(PY_SSIZE_T_MAX + 1)
        if width <= sys.maxint:
            self.checkraises(OverflowError, '%*s', '__mod__', (width, ''))
        prec = int(INT_MAX + 1)
        if prec <= sys.maxint:
            self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7))
        # Issue 15989
        width = int(SIZE_MAX + 1)
        if width <= sys.maxint:
            self.checkraises(OverflowError, '%*s', '__mod__', (width, ''))
        prec = int(UINT_MAX + 1)
        if prec <= sys.maxint:
            self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:18,代碼來源:string_tests.py

示例2: test_poll3

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_poll3(self):
        # test int overflow
        pollster = select.poll()
        pollster.register(1)

        self.assertRaises(OverflowError, pollster.poll, 1L << 64)

        x = 2 + 3
        if x != 5:
            self.fail('Overflow must have occurred')

        pollster = select.poll()
        # Issue 15989
        self.assertRaises(OverflowError, pollster.register, 0,
                          _testcapi.SHRT_MAX + 1)
        self.assertRaises(OverflowError, pollster.register, 0,
                          _testcapi.USHRT_MAX + 1)
        self.assertRaises(OverflowError, pollster.poll, _testcapi.INT_MAX + 1)
        self.assertRaises(OverflowError, pollster.poll, _testcapi.UINT_MAX + 1) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:21,代碼來源:test_poll.py

示例3: test_fcntl_bad_file

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_fcntl_bad_file(self):
        class F:
            def __init__(self, fn):
                self.fn = fn
            def fileno(self):
                return self.fn
        self.assertRaises(ValueError, fcntl.fcntl, -1, fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(ValueError, fcntl.fcntl, F(-1), fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(TypeError, fcntl.fcntl, 'spam', fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(TypeError, fcntl.fcntl, F('spam'), fcntl.F_SETFL, os.O_NONBLOCK)
        # Issue 15989
        self.assertRaises(ValueError, fcntl.fcntl, _testcapi.INT_MAX + 1,
                                                   fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(ValueError, fcntl.fcntl, F(_testcapi.INT_MAX + 1),
                                                   fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(ValueError, fcntl.fcntl, _testcapi.INT_MIN - 1,
                                                   fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(ValueError, fcntl.fcntl, F(_testcapi.INT_MIN - 1),
                                                   fcntl.F_SETFL, os.O_NONBLOCK) 
開發者ID:Acmesec,項目名稱:CTFCrackTools-V2,代碼行數:21,代碼來源:test_fcntl.py

示例4: test_listen_backlog_overflow

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_listen_backlog_overflow(self):
        # Issue 15989
        import _testcapi
        srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        srv.bind((HOST, 0))
        self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1)
        srv.close() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_socket.py

示例5: _testShutdown_overflow

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def _testShutdown_overflow(self):
        import _testcapi
        self.serv_conn.send(MSG)
        # Issue 15989
        self.assertRaises(OverflowError, self.serv_conn.shutdown,
                          _testcapi.INT_MAX + 1)
        self.assertRaises(OverflowError, self.serv_conn.shutdown,
                          2 + (_testcapi.UINT_MAX + 1))
        self.serv_conn.shutdown(2) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_socket.py

示例6: test_poll_c_limits

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_poll_c_limits(self):
        from _testcapi import USHRT_MAX, INT_MAX, UINT_MAX
        pollster = select.poll()
        pollster.register(1)

        # Issues #15989, #17919
        self.assertRaises(OverflowError, pollster.register, 0, USHRT_MAX + 1)
        self.assertRaises(OverflowError, pollster.modify, 1, USHRT_MAX + 1)
        self.assertRaises(OverflowError, pollster.poll, INT_MAX + 1)
        self.assertRaises(OverflowError, pollster.poll, UINT_MAX + 1) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:test_poll.py

示例7: test_main

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_main():
    test_support.run_unittest(FormatTest)

    def test_precision(self):
        f = 1.2
        self.assertEqual(format(f, ".0f"), "1")
        self.assertEqual(format(f, ".3f"), "1.200")
        with self.assertRaises(ValueError) as cm:
            format(f, ".%sf" % (sys.maxsize + 1))
        self.assertEqual(str(cm.exception), "precision too big")

        c = complex(f)
        self.assertEqual(format(c, ".0f"), "1+0j")
        self.assertEqual(format(c, ".3f"), "1.200+0.000j")
        with self.assertRaises(ValueError) as cm:
            format(c, ".%sf" % (sys.maxsize + 1))
        self.assertEqual(str(cm.exception), "precision too big")

    @test_support.cpython_only
    def test_precision_c_limits(self):
        from _testcapi import INT_MAX

        f = 1.2
        with self.assertRaises(ValueError) as cm:
            format(f, ".%sf" % (INT_MAX + 1))

        c = complex(f)
        with self.assertRaises(ValueError) as cm:
            format(c, ".%sf" % (INT_MAX + 1)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:31,代碼來源:test_format.py

示例8: test_fcntl_bad_file_overflow

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_fcntl_bad_file_overflow(self):
        from _testcapi import INT_MAX, INT_MIN
        # Issue 15989
        with self.assertRaises(ValueError):
            fcntl.fcntl(INT_MAX + 1, fcntl.F_SETFL, os.O_NONBLOCK)
        with self.assertRaises(ValueError):
            fcntl.fcntl(BadFile(INT_MAX + 1), fcntl.F_SETFL, os.O_NONBLOCK)
        with self.assertRaises(ValueError):
            fcntl.fcntl(INT_MIN - 1, fcntl.F_SETFL, os.O_NONBLOCK)
        with self.assertRaises(ValueError):
            fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:test_fcntl.py

示例9: testInvalidFd_overflow

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def testInvalidFd_overflow(self):
        # Issue 15989
        import _testcapi
        self.assertRaises(TypeError, _FileIO, _testcapi.INT_MAX + 1)
        self.assertRaises(TypeError, _FileIO, _testcapi.INT_MIN - 1) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_fileio.py

示例10: test_formatting_huge_precision

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_formatting_huge_precision(self):
        from _testcapi import INT_MAX
        format_string = "%.{}f".format(INT_MAX + 1)
        with self.assertRaises(ValueError):
            result = format_string % 2.34 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_str.py

示例11: test_listen_backlog

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_listen_backlog(self):
        for backlog in 0, -1:
            srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            srv.bind((HOST, 0))
            srv.listen(backlog)
            srv.close()

        # Issue 15989
        srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        srv.bind((HOST, 0))
        self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1)
        srv.close() 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:14,代碼來源:test_socket.py

示例12: _testShutdown

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def _testShutdown(self):
        self.serv_conn.send(MSG)
        # Issue 15989
        self.assertRaises(OverflowError, self.serv_conn.shutdown,
                          _testcapi.INT_MAX + 1)
        self.assertRaises(OverflowError, self.serv_conn.shutdown,
                          2 + (_testcapi.UINT_MAX + 1))
        self.serv_conn.shutdown(2) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:10,代碼來源:test_socket.py

示例13: test_formatting_huge_precision

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_formatting_huge_precision(self):
        from _testcapi import INT_MAX
        format_string = u"%.{}f".format(INT_MAX + 1)
        with self.assertRaises(ValueError):
            result = format_string % 2.34 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:7,代碼來源:test_unicode.py

示例14: testInvalidFd

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def testInvalidFd(self):
        self.assertRaises(ValueError, _FileIO, -10)
        self.assertRaises(OSError, _FileIO, make_bad_fd())
        if sys.platform == 'win32':
            import msvcrt
            self.assertRaises(IOError, msvcrt.get_osfhandle, make_bad_fd())
        # Issue 15989
        self.assertRaises(TypeError, _FileIO, _testcapi.INT_MAX + 1)
        self.assertRaises(TypeError, _FileIO, _testcapi.INT_MIN - 1) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:11,代碼來源:test_fileio.py

示例15: test_device_encoding

# 需要導入模塊: import _testcapi [as 別名]
# 或者: from _testcapi import INT_MAX [as 別名]
def test_device_encoding(self):
        # Issue 15989
        import _testcapi
        b = self.BytesIO()
        b.fileno = lambda: _testcapi.INT_MAX + 1
        self.assertRaises(OverflowError, self.TextIOWrapper, b)
        b.fileno = lambda: _testcapi.UINT_MAX + 1
        self.assertRaises(OverflowError, self.TextIOWrapper, b) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:10,代碼來源:test_io.py


注:本文中的_testcapi.INT_MAX屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。