agent-exec transport d746852ae50f236002975c61a064caa9/397c60bd1367

This commit is contained in:
agent-exec-transport
2026-10-21 10:27:21 +00:00
parent 88aa4b6b7d
commit 70c810a030
4 changed files with 64 additions and 14 deletions
+24
View File
@@ -0,0 +1,24 @@
"""Regression for tests/_port_alloc.free_test_port."""
import os
import socket
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from _port_alloc import free_test_port # noqa: E402
class FreeTestPortTests(unittest.TestCase):
def test_two_calls_return_distinct_bindable_ports(self):
first = free_test_port()
second = free_test_port()
self.assertNotEqual(first, second)
for port in (first, second):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as listener:
listener.bind(("127.0.0.1", port))
listener.listen(1)
self.assertEqual(listener.getsockname()[1], port)
if __name__ == "__main__":
unittest.main()