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

Method test_reuse_port

Lib/test/test_socket.py:7366–7376  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7364 self.assertEqual(sock.type, socket.SOCK_STREAM)
7365
7366 def test_reuse_port(self):
7367 if not hasattr(socket, "SO_REUSEPORT"):
7368 with self.assertRaises(ValueError):
7369 socket.create_server(("localhost", 0), reuse_port=True)
7370 else:
7371 with socket.create_server(("localhost", 0)) as sock:
7372 opt = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)
7373 self.assertEqual(opt, 0)
7374 with socket.create_server(("localhost", 0), reuse_port=True) as sock:
7375 opt = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)
7376 self.assertNotEqual(opt, 0)
7377
7378 @unittest.skipIf(not hasattr(_socket, 'IPPROTO_IPV6') or
7379 not hasattr(_socket, 'IPV6_V6ONLY'),

Callers

nothing calls this directly

Calls 5

assertNotEqualMethod · 0.80
assertRaisesMethod · 0.45
create_serverMethod · 0.45
getsockoptMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected