Python _testcapi.UINT_MAX Examples

The following are 30 code examples of _testcapi.UINT_MAX(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module _testcapi , or try the search function .
Example #1
Source Project: BinderFilter   Author: dxwu   File: test_socket.py    License: MIT License 6 votes vote down vote up
def testSetBlocking(self):
        # Testing whether set blocking works
        self.serv.setblocking(True)
        self.assertIsNone(self.serv.gettimeout())
        self.serv.setblocking(False)
        self.assertEqual(self.serv.gettimeout(), 0.0)
        start = time.time()
        try:
            self.serv.accept()
        except socket.error:
            pass
        end = time.time()
        self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.")
        # Issue 15989
        if _testcapi.UINT_MAX < _testcapi.ULONG_MAX:
            self.serv.setblocking(_testcapi.UINT_MAX + 1)
            self.assertIsNone(self.serv.gettimeout()) 
Example #2
Source Project: BinderFilter   Author: dxwu   File: test_poll.py    License: MIT License 6 votes vote down vote up
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) 
Example #3
Source Project: gcblue   Author: gcblue   File: string_tests.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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)) 
Example #4
Source Project: ironpython2   Author: IronLanguages   File: test_socket.py    License: Apache License 2.0 5 votes vote down vote up
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) 
Example #5
Source Project: ironpython2   Author: IronLanguages   File: test_socket.py    License: Apache License 2.0 5 votes vote down vote up
def testSetBlocking_overflow(self):
        # Issue 15989
        import _testcapi
        if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX:
            self.skipTest('needs UINT_MAX < ULONG_MAX')
        self.serv.setblocking(False)
        self.assertEqual(self.serv.gettimeout(), 0.0)
        self.serv.setblocking(_testcapi.UINT_MAX + 1)
        self.assertIsNone(self.serv.gettimeout()) 
Example #6
Source Project: ironpython2   Author: IronLanguages   File: test_poll.py    License: Apache License 2.0 5 votes vote down vote up
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) 
Example #7
Source Project: ironpython2   Author: IronLanguages   File: test_ucn.py    License: Apache License 2.0 5 votes vote down vote up
def test_issue16335(self, size):
        func = self.test_issue16335
        if size < func.minsize:
            raise unittest.SkipTest("not enough memory: %.1fG minimum needed" %
                    (func.minsize * func.memuse / float(1024**3),))
        # very very long bogus character name
        x = b'\\N{SPACE' + b'x' * int(UINT_MAX + 1) + b'}'
        self.assertEqual(len(x), len(b'\\N{SPACE}') + (UINT_MAX + 1))
        self.assertRaisesRegexp(UnicodeError,
            'unknown Unicode character name',
            x.decode, 'unicode-escape'
        ) 
Example #8
Source Project: BinderFilter   Author: dxwu   File: test_socket.py    License: MIT License 5 votes vote down vote up
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) 
Example #9
Source Project: BinderFilter   Author: dxwu   File: test_ucn.py    License: MIT License 5 votes vote down vote up
def test_issue16335(self, size):
        func = self.test_issue16335
        if size < func.minsize:
            raise unittest.SkipTest("not enough memory: %.1fG minimum needed" %
                    (func.minsize * func.memuse / float(1024**3),))
        # very very long bogus character name
        x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}'
        self.assertEqual(len(x), len(b'\\N{SPACE}') +
                                    (_testcapi.UINT_MAX + 1))
        self.assertRaisesRegexp(UnicodeError,
            'unknown Unicode character name',
            x.decode, 'unicode-escape'
        ) 
Example #10
Source Project: oss-ftp   Author: aliyun   File: test_socket.py    License: MIT License 5 votes vote down vote up
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) 
Example #11
Source Project: oss-ftp   Author: aliyun   File: test_socket.py    License: MIT License 5 votes vote down vote up
def testSetBlocking_overflow(self):
        # Issue 15989
        import _testcapi
        if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX:
            self.skipTest('needs UINT_MAX < ULONG_MAX')
        self.serv.setblocking(False)
        self.assertEqual(self.serv.gettimeout(), 0.0)
        self.serv.setblocking(_testcapi.UINT_MAX + 1)
        self.assertIsNone(self.serv.gettimeout()) 
Example #12
Source Project: oss-ftp   Author: aliyun   File: test_poll.py    License: MIT License 5 votes vote down vote up
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) 
Example #13
Source Project: oss-ftp   Author: aliyun   File: test_ucn.py    License: MIT License 5 votes vote down vote up
def test_issue16335(self, size):
        func = self.test_issue16335
        if size < func.minsize:
            raise unittest.SkipTest("not enough memory: %.1fG minimum needed" %
                    (func.minsize * func.memuse / float(1024**3),))
        # very very long bogus character name
        x = b'\\N{SPACE' + b'x' * int(UINT_MAX + 1) + b'}'
        self.assertEqual(len(x), len(b'\\N{SPACE}') + (UINT_MAX + 1))
        self.assertRaisesRegexp(UnicodeError,
            'unknown Unicode character name',
            x.decode, 'unicode-escape'
        ) 
Example #14
Source Project: Fluid-Designer   Author: Microvellum   File: test_socket.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #15
Source Project: Fluid-Designer   Author: Microvellum   File: test_socket.py    License: GNU General Public License v3.0 5 votes vote down vote up
def testSetBlocking_overflow(self):
        # Issue 15989
        import _testcapi
        if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX:
            self.skipTest('needs UINT_MAX < ULONG_MAX')
        self.serv.setblocking(False)
        self.assertEqual(self.serv.gettimeout(), 0.0)
        self.serv.setblocking(_testcapi.UINT_MAX + 1)
        self.assertIsNone(self.serv.gettimeout()) 
Example #16
Source Project: Fluid-Designer   Author: Microvellum   File: test_io.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #17
Source Project: Fluid-Designer   Author: Microvellum   File: test_poll.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #18
Source Project: Fluid-Designer   Author: Microvellum   File: test_posix.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_pipe2_c_limits(self):
        # Issue 15989
        import _testcapi
        self.assertRaises(OverflowError, os.pipe2, _testcapi.INT_MAX + 1)
        self.assertRaises(OverflowError, os.pipe2, _testcapi.UINT_MAX + 1) 
Example #19
Source Project: Fluid-Designer   Author: Microvellum   File: string_tests.py    License: GNU General Public License v3.0 5 votes vote down vote up
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
        self.checkraises(OverflowError, '%*s', '__mod__',
                         (PY_SSIZE_T_MAX + 1, ''))
        self.checkraises(OverflowError, '%.*f', '__mod__',
                         (INT_MAX + 1, 1. / 7))
        # Issue 15989
        self.checkraises(OverflowError, '%*s', '__mod__',
                         (SIZE_MAX + 1, ''))
        self.checkraises(OverflowError, '%.*f', '__mod__',
                         (UINT_MAX + 1, 1. / 7)) 
Example #20
Source Project: Imogen   Author: CedricGuillemet   File: test_structures.py    License: MIT License 5 votes vote down vote up
def test_packed_c_limits(self):
        # Issue 15989
        import _testcapi
        d = {"_fields_": [("a", c_byte)],
             "_pack_": _testcapi.INT_MAX + 1}
        self.assertRaises(ValueError, type(Structure), "X", (Structure,), d)
        d = {"_fields_": [("a", c_byte)],
             "_pack_": _testcapi.UINT_MAX + 2}
        self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) 
Example #21
Source Project: ironpython3   Author: IronLanguages   File: test_socket.py    License: Apache License 2.0 5 votes vote down vote up
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) 
Example #22
Source Project: ironpython3   Author: IronLanguages   File: test_socket.py    License: Apache License 2.0 5 votes vote down vote up
def testSetBlocking_overflow(self):
        # Issue 15989
        import _testcapi
        if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX:
            self.skipTest('needs UINT_MAX < ULONG_MAX')
        self.serv.setblocking(False)
        self.assertEqual(self.serv.gettimeout(), 0.0)
        self.serv.setblocking(_testcapi.UINT_MAX + 1)
        self.assertIsNone(self.serv.gettimeout()) 
Example #23
Source Project: ironpython3   Author: IronLanguages   File: test_io.py    License: Apache License 2.0 5 votes vote down vote up
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) 
Example #24
Source Project: ironpython3   Author: IronLanguages   File: test_poll.py    License: Apache License 2.0 5 votes vote down vote up
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) 
Example #25
Source Project: ironpython3   Author: IronLanguages   File: test_posix.py    License: Apache License 2.0 5 votes vote down vote up
def test_pipe2_c_limits(self):
        # Issue 15989
        import _testcapi
        self.assertRaises(OverflowError, os.pipe2, _testcapi.INT_MAX + 1)
        self.assertRaises(OverflowError, os.pipe2, _testcapi.UINT_MAX + 1) 
Example #26
Source Project: ironpython3   Author: IronLanguages   File: string_tests.py    License: Apache License 2.0 5 votes vote down vote up
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
        self.checkraises(OverflowError, '%*s', '__mod__',
                         (PY_SSIZE_T_MAX + 1, ''))
        self.checkraises(OverflowError, '%.*f', '__mod__',
                         (INT_MAX + 1, 1. / 7))
        # Issue 15989
        self.checkraises(OverflowError, '%*s', '__mod__',
                         (SIZE_MAX + 1, ''))
        self.checkraises(OverflowError, '%.*f', '__mod__',
                         (UINT_MAX + 1, 1. / 7)) 
Example #27
Source Project: gcblue   Author: gcblue   File: test_socket.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #28
Source Project: gcblue   Author: gcblue   File: test_socket.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testSetBlocking_overflow(self):
        # Issue 15989
        import _testcapi
        if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX:
            self.skipTest('needs UINT_MAX < ULONG_MAX')
        self.serv.setblocking(False)
        self.assertEqual(self.serv.gettimeout(), 0.0)
        self.serv.setblocking(_testcapi.UINT_MAX + 1)
        self.assertIsNone(self.serv.gettimeout()) 
Example #29
Source Project: gcblue   Author: gcblue   File: test_poll.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #30
Source Project: gcblue   Author: gcblue   File: test_ucn.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_issue16335(self, size):
        func = self.test_issue16335
        if size < func.minsize:
            raise unittest.SkipTest("not enough memory: %.1fG minimum needed" %
                    (func.minsize * func.memuse / float(1024**3),))
        # very very long bogus character name
        x = b'\\N{SPACE' + b'x' * int(UINT_MAX + 1) + b'}'
        self.assertEqual(len(x), len(b'\\N{SPACE}') + (UINT_MAX + 1))
        self.assertRaisesRegexp(UnicodeError,
            'unknown Unicode character name',
            x.decode, 'unicode-escape'
        )