Exemple #1
0
 def testInvalidFd(self):
     self.assertRaises(ValueError, _FileIO, -10)
     self.assertRaises(OSError, _FileIO, make_bad_fd())
     if sys.platform == 'win32':
         raise unittest.SkipTest('Set _invalid_parameter_handler for low level io')
         import msvcrt
         self.assertRaises(IOError, msvcrt.get_osfhandle, make_bad_fd())
Exemple #2
0
 def testInvalidFd(self):
     self.assertRaises(ValueError, _FileIO, -10)
     self.assertRaises(OSError, _FileIO, make_bad_fd())
     if sys.platform == 'win32':
         raise unittest.SkipTest(
             'Set _invalid_parameter_handler for low level io')
         import msvcrt
         self.assertRaises(IOError, msvcrt.get_osfhandle, make_bad_fd())
Exemple #3
0
 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)
Exemple #4
0
 def testInvalidFd(self):
     if is_jython:
         self.assertRaises(TypeError, _FileIO, -10)  # file descriptor not int in Jython
     else:
         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())
Exemple #5
0
 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)
Exemple #6
0
 def testInvalidFd(self):
     if is_jython:
         self.assertRaises(TypeError, _FileIO,
                           -10)  # file descriptor not int in Jython
     else:
         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())
Exemple #7
0
 def check(self, f, *args):
     try:
         f(test_support.make_bad_fd(), *args)
     except OSError as e:
         self.assertEqual(e.errno, errno.EBADF)
     else:
         self.fail("%r didn't raise a OSError with a bad file descriptor" % f)
 def check(self, f, *args):
     try:
         f(test_support.make_bad_fd(), *args)
     except OSError as e:
         self.assertEqual(e.errno, errno.EBADF)
     else:
         self.fail("%r didn't raise an OSError with a bad file descriptor"
                   % f)
Exemple #9
0
 def check(self, f, *args):
     try:
         fd = test_support.make_bad_fd()
         f(fd, *args)
     except OSError as e:
         self.assertEqual(e.errno, errno.EBADF)
     except ValueError:
         self.assertTrue(test_support.is_jython)
     else:
         self.fail("%r didn't raise a OSError with a bad file descriptor" %
                   f)
 def check(self, f, *args):
     try:
         fd = test_support.make_bad_fd()
         f(fd, *args)
     except OSError as e:
         self.assertEqual(e.errno, errno.EBADF)
     except ValueError:
         self.assertTrue(test_support.is_jython)
     else:
         self.fail("%r didn't raise a OSError with a bad file descriptor"
                   % f)
 def test_closerange(self):
     fd = test_support.make_bad_fd()
     # Make sure none of the descriptors we are about to close are
     # currently valid (issue 6542).
     for i in range(10):
         try: os.fstat(fd+i)
         except OSError:
             pass
         else:
             break
     if i < 2:
         raise unittest.SkipTest(
             "Unable to acquire a range of invalid file descriptors")
     self.assertEqual(os.closerange(fd, fd + i-1), None)
 def test_closerange(self):
     if hasattr(os, "closerange"):
         fd = int(test_support.make_bad_fd())  # need to take an int for Jython, given this test
         # Make sure none of the descriptors we are about to close are
         # currently valid (issue 6542).
         for i in range(10):
             try: os.fstat(fd+i)
             except OSError:
                 pass
             else:
                 break
         if i < 2:
             raise unittest.SkipTest(
                 "Unable to acquire a range of invalid file descriptors")
         self.assertEqual(os.closerange(fd, fd + i-1), None)
Exemple #13
0
 def test_closerange(self):
     if hasattr(os, "closerange"):
         fd = test_support.make_bad_fd()
         # Make sure none of the descriptors we are about to close are
         # currently valid (issue 6542).
         for i in range(10):
             try: os.fstat(fd+i)
             except OSError:
                 pass
             else:
                 break
         if i < 2:
             # Unable to acquire a range of invalid file descriptors,
             # so skip the test (in 2.6+ this is a unittest.SkipTest).
             return
         self.assertEqual(os.closerange(fd, fd + i-1), None)
Exemple #14
0
 def test_closerange(self):
     if hasattr(os, "closerange"):
         fd = test_support.make_bad_fd()
         # Make sure none of the descriptors we are about to close are
         # currently valid (issue 6542).
         for i in range(10):
             try: os.fstat(fd+i)
             except OSError:
                 pass
             else:
                 break
         if i < 2:
             # Unable to acquire a range of invalid file descriptors,
             # so skip the test (in 2.6+ this is a unittest.SkipTest).
             return
         self.assertEqual(os.closerange(fd, fd + i-1), None)
Exemple #15
0
 def test_closerange(self):
     if hasattr(os, "closerange"):
         fd = int(test_support.make_bad_fd()
                  )  # need to take an int for Jython, given this test
         # Make sure none of the descriptors we are about to close are
         # currently valid (issue 6542).
         for i in range(10):
             try:
                 os.fstat(fd + i)
             except OSError:
                 pass
             else:
                 break
         if i < 2:
             raise unittest.SkipTest(
                 "Unable to acquire a range of invalid file descriptors")
         self.assertEqual(os.closerange(fd, fd + i - 1), None)
Exemple #16
0
 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())
Exemple #17
0
 def test_ftruncate(self):
     if hasattr(os, "ftruncate"):
         self.assertRaises(IOError, os.ftruncate, test_support.make_bad_fd(),
                           0)
Exemple #18
0
 def check(self, f, *args):
     self.assertRaises(OSError, f, test_support.make_bad_fd(), *args)
Exemple #19
0
 def test_closerange(self):
     if hasattr(os, "closerange"):
         fd = test_support.make_bad_fd()
         self.assertEqual(os.closerange(fd, fd + 10), None)
 def test_invalid_fd(self):
     fd = test_support.make_bad_fd()
     self.assertRaises(ValueError, signal.set_wakeup_fd, fd)
Exemple #21
0
 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())
Exemple #22
0
 def test_ftruncate(self):
     if hasattr(os, "ftruncate"):
         self.assertRaises(IOError, os.ftruncate,
                           test_support.make_bad_fd(), 0)
Exemple #23
0
 def check(self, f, *args):
     self.assertRaises(OSError, f, test_support.make_bad_fd(), *args)
Exemple #24
0
 def test_invalid_fd(self):
     fd = test_support.make_bad_fd()
     self.assertRaises(ValueError, signal.set_wakeup_fd, fd)
Exemple #25
0
 def test_closerange(self):
     if hasattr(os, "closerange"):
         fd = test_support.make_bad_fd()
         self.assertEqual(os.closerange(fd, fd + 10), None)
 def test_isatty(self):
     self.assertEqual(os.isatty(test_support.make_bad_fd()), False)
Exemple #27
0
 def testInvalidFd(self):
     self.assertRaises(ValueError, _fileio._FileIO, -10)
     self.assertRaises(OSError, _fileio._FileIO, make_bad_fd())
Exemple #28
0
 def testInvalidFd(self):
     self.assertRaises(ValueError, _fileio._FileIO, -10)
     self.assertRaises(OSError, _fileio._FileIO, make_bad_fd())
Exemple #29
0
 def testInvalidFd(self):  # replaces that of the stdlib
     self.assertRaises(ValueError, io.open, -10, 'wb', buffering=0, )
     bad_fd = test_support.make_bad_fd()
     self.assertRaises(IOError, io.open, bad_fd, 'wb', buffering=0)