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

Method test_makefile_close

Lib/test/test_ssl.py:2221–2237  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2219
2220 @unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows")
2221 def test_makefile_close(self):
2222 # Issue #5238: creating a file-like object with makefile() shouldn't
2223 # delay closing the underlying "real socket" (here tested with its
2224 # file descriptor, hence skipping the test under Windows).
2225 ss = test_wrap_socket(socket.socket(socket.AF_INET))
2226 ss.connect(self.server_addr)
2227 fd = ss.fileno()
2228 f = ss.makefile()
2229 f.close()
2230 # The fd is still open
2231 os.read(fd, 0)
2232 # Closing the SSL socket should close the fd too
2233 ss.close()
2234 gc.collect()
2235 with self.assertRaises(OSError) as e:
2236 os.read(fd, 0)
2237 self.assertEqual(e.exception.errno, errno.EBADF)
2238
2239 def test_non_blocking_handshake(self):
2240 s = socket.socket(socket.AF_INET)

Callers

nothing calls this directly

Calls 10

test_wrap_socketFunction · 0.85
socketMethod · 0.80
connectMethod · 0.45
filenoMethod · 0.45
makefileMethod · 0.45
closeMethod · 0.45
readMethod · 0.45
collectMethod · 0.45
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected