示例#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())
示例#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())
示例#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)
示例#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())
示例#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)
示例#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())
示例#7
0
文件: test_os.py 项目: van7hu/fanca
 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)
示例#8
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 an OSError with a bad file descriptor"
                   % f)
示例#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)
示例#10
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)
示例#11
0
 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)
示例#12
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)
示例#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)
示例#14
0
文件: test_os.py 项目: tczf1128/zk
 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)
示例#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)
示例#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())
示例#17
0
文件: test_os.py 项目: tczf1128/zk
 def test_ftruncate(self):
     if hasattr(os, "ftruncate"):
         self.assertRaises(IOError, os.ftruncate, test_support.make_bad_fd(),
                           0)
示例#18
0
文件: test_os.py 项目: tczf1128/zk
 def check(self, f, *args):
     self.assertRaises(OSError, f, test_support.make_bad_fd(), *args)
示例#19
0
 def test_closerange(self):
     if hasattr(os, "closerange"):
         fd = test_support.make_bad_fd()
         self.assertEqual(os.closerange(fd, fd + 10), None)
示例#20
0
 def test_invalid_fd(self):
     fd = test_support.make_bad_fd()
     self.assertRaises(ValueError, signal.set_wakeup_fd, fd)
示例#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())
示例#22
0
文件: test_os.py 项目: redb/MNPP
 def test_ftruncate(self):
     if hasattr(os, "ftruncate"):
         self.assertRaises(IOError, os.ftruncate,
                           test_support.make_bad_fd(), 0)
示例#23
0
文件: test_os.py 项目: redb/MNPP
 def check(self, f, *args):
     self.assertRaises(OSError, f, test_support.make_bad_fd(), *args)
示例#24
0
 def test_invalid_fd(self):
     fd = test_support.make_bad_fd()
     self.assertRaises(ValueError, signal.set_wakeup_fd, fd)
示例#25
0
 def test_closerange(self):
     if hasattr(os, "closerange"):
         fd = test_support.make_bad_fd()
         self.assertEqual(os.closerange(fd, fd + 10), None)
示例#26
0
 def test_isatty(self):
     self.assertEqual(os.isatty(test_support.make_bad_fd()), False)
示例#27
0
 def testInvalidFd(self):
     self.assertRaises(ValueError, _fileio._FileIO, -10)
     self.assertRaises(OSError, _fileio._FileIO, make_bad_fd())
示例#28
0
 def testInvalidFd(self):
     self.assertRaises(ValueError, _fileio._FileIO, -10)
     self.assertRaises(OSError, _fileio._FileIO, make_bad_fd())
示例#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)