本文整理汇总了Python中test.support.make_bad_fd函数的典型用法代码示例。如果您正苦于以下问题:Python make_bad_fd函数的具体用法?Python make_bad_fd怎么用?Python make_bad_fd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_bad_fd函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testInvalidFd
def testInvalidFd(self):
self.assertRaises(ValueError, _FileIO, -10)
self.assertRaises(OSError, _FileIO, make_bad_fd())
if sys.platform == 'win32':
import msvcrt
self.assertRaises(OSError, 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:GuardianRG,项目名称:static-python,代码行数:9,代码来源:test_fileio.py
示例2: testInvalidFd
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())
开发者ID:isaiah,项目名称:jython3,代码行数:9,代码来源:test_fileio.py
示例3: check
def check(self, f, *args):
try:
f(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)
开发者ID:baohaojun,项目名称:ext-local,代码行数:7,代码来源:test_os.py
示例4: test_register_bad_fd
def test_register_bad_fd(self):
# a file descriptor that's been closed should raise an OSError
# with EBADF
s = self.SELECTOR()
bad_f = support.make_bad_fd()
with self.assertRaises(OSError) as cm:
s.register(bad_f, selectors.EVENT_READ)
self.assertEqual(cm.exception.errno, errno.EBADF)
# the SelectorKey has been removed
with self.assertRaises(KeyError):
s.get_key(bad_f)
开发者ID:M31MOTH,项目名称:cpython,代码行数:11,代码来源:test_selectors.py
示例5: check
def check(self, f, *args):
try:
fd = support.make_bad_fd()
f(fd, *args)
except OSError as e:
self.assertEqual(e.errno, errno.EBADF)
except ValueError:
self.assertTrue(support.is_jython)
else:
self.fail("%r didn't raise a OSError with a bad file descriptor"
% f)
开发者ID:isaiah,项目名称:jython3,代码行数:11,代码来源:test_os.py
示例6: test_closerange
def test_closerange(self):
if hasattr(os, "closerange"):
fd = 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)
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:15,代码来源:test_os.py
示例7: testInvalidFd
def testInvalidFd(self):
self.assertRaises(ValueError, self.FileIO, -10)
self.assertRaises(OSError, self.FileIO, make_bad_fd())
if sys.platform == 'win32':
import msvcrt
self.assertRaises(OSError, msvcrt.get_osfhandle, make_bad_fd())
开发者ID:ARK4579,项目名称:cpython,代码行数:6,代码来源:test_fileio.py
示例8: test_invalid_fd
def test_invalid_fd(self):
fd = support.make_bad_fd()
self.assertRaises((ValueError, OSError),
signal.set_wakeup_fd, fd)
开发者ID:Eyepea,项目名称:cpython,代码行数:4,代码来源:test_signal.py
示例9: test_make_bad_fd
def test_make_bad_fd(self):
fd = support.make_bad_fd()
with self.assertRaises(OSError) as cm:
os.write(fd, b"foo")
self.assertEqual(cm.exception.errno, errno.EBADF)
开发者ID:MYSHLIFE,项目名称:cpython-1,代码行数:5,代码来源:test_support.py
示例10: test_isatty
def test_isatty(self):
if hasattr(os, "isatty"):
self.assertEqual(os.isatty(support.make_bad_fd()), False)
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:3,代码来源:test_os.py
注:本文中的test.support.make_bad_fd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论