本文整理汇总了Python中test.support.make_bad_fd方法的典型用法代码示例。如果您正苦于以下问题:Python support.make_bad_fd方法的具体用法?Python support.make_bad_fd怎么用?Python support.make_bad_fd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.support
的用法示例。
在下文中一共展示了support.make_bad_fd方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_make_bad_fd
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import make_bad_fd [as 别名]
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)
示例2: test_invalid_fd
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import make_bad_fd [as 别名]
def test_invalid_fd(self):
fd = support.make_bad_fd()
self.assertRaises((ValueError, OSError),
signal.set_wakeup_fd, fd)
示例3: check
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import make_bad_fd [as 别名]
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 an OSError with a bad file descriptor"
% f)
示例4: test_isatty
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import make_bad_fd [as 别名]
def test_isatty(self):
self.assertEqual(os.isatty(support.make_bad_fd()), False)
示例5: test_closerange
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import make_bad_fd [as 别名]
def test_closerange(self):
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)
示例6: test_invalid_fd
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import make_bad_fd [as 别名]
def test_invalid_fd(self):
fd = support.make_bad_fd()
self.assertRaises(ValueError, signal.set_wakeup_fd, fd)
示例7: test_register_bad_fd
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import make_bad_fd [as 别名]
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)