MCPcopy Index your code
hub / github.com/python/cpython / test_close

Method test_close

Lib/test/test_epoll.py:238–260  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

236 self.assertEqual(cm.exception.errno, errno.EBADF)
237
238 def test_close(self):
239 open_file = open(__file__, "rb")
240 self.addCleanup(open_file.close)
241 fd = open_file.fileno()
242 epoll = select.epoll()
243
244 # test fileno() method and closed attribute
245 self.assertIsInstance(epoll.fileno(), int)
246 self.assertFalse(epoll.closed)
247
248 # test close()
249 epoll.close()
250 self.assertTrue(epoll.closed)
251 self.assertRaises(ValueError, epoll.fileno)
252
253 # close() can be called more than once
254 epoll.close()
255
256 # operations must fail with ValueError("I/O operation on closed ...")
257 self.assertRaises(ValueError, epoll.modify, fd, select.EPOLLIN)
258 self.assertRaises(ValueError, epoll.poll, 1.0)
259 self.assertRaises(ValueError, epoll.register, fd, select.EPOLLIN)
260 self.assertRaises(ValueError, epoll.unregister, fd)
261
262 def test_close_error(self):
263 # gh-146205: close() should raise OSError if underlying fd is invalid

Callers

nothing calls this directly

Calls 8

addCleanupMethod · 0.80
assertIsInstanceMethod · 0.80
assertFalseMethod · 0.80
assertTrueMethod · 0.80
openFunction · 0.50
filenoMethod · 0.45
closeMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected