agent-exec transport d746852ae50f236002975c61a064caa9/397c60bd1367
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user