bpo-34932: Add socket.TCP_KEEPALIVE for macOS (GH-25079)
(cherry picked from commit d59d7374a364c4e5c2b9a83d8e4543ee494285b8)
Co-authored-by: Shane Harvey <shnhrv@gmail.com>
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index a59afd4..12af22f 100755
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -6411,6 +6411,12 @@ def test_length_restriction(self):
sock.bind(("type", "n" * 64))
+@unittest.skipUnless(sys.platform == 'darwin', 'macOS specific test')
+class TestMacOSTCPFlags(unittest.TestCase):
+ def test_tcp_keepalive(self):
+ self.assertTrue(socket.TCP_KEEPALIVE)
+
+
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
class TestMSWindowsTCPFlags(unittest.TestCase):
knownTCPFlags = {
@@ -6669,6 +6675,7 @@ def test_main():
SendfileUsingSendfileTest,
])
tests.append(TestMSWindowsTCPFlags)
+ tests.append(TestMacOSTCPFlags)
thread_info = threading_helper.threading_setup()
support.run_unittest(*tests)