File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -564,23 +564,9 @@ def testStringToIPv6(self):
564564
565565 # XXX The following don't test module-level functionality...
566566
567- def _get_unused_port (self , bind_address = '0.0.0.0' ):
568- """Use a temporary socket to elicit an unused ephemeral port.
569-
570- Args:
571- bind_address: Hostname or IP address to search for a port on.
572-
573- Returns: A most likely to be unused port.
574- """
575- tempsock = socket .socket ()
576- tempsock .bind ((bind_address , 0 ))
577- host , port = tempsock .getsockname ()
578- tempsock .close ()
579- return port
580-
581567 def testSockName (self ):
582568 # Testing getsockname()
583- port = self . _get_unused_port ()
569+ port = support . find_unused_port ()
584570 sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
585571 self .addCleanup (sock .close )
586572 sock .bind (("0.0.0.0" , port ))
@@ -629,7 +615,7 @@ def testNewAttributes(self):
629615
630616 def test_getsockaddrarg (self ):
631617 host = '0.0.0.0'
632- port = self . _get_unused_port ( bind_address = host )
618+ port = support . find_unused_port ( )
633619 big_port = port + 65536
634620 neg_port = port - 65536
635621 sock = socket .socket ()
You can’t perform that action at this time.
0 commit comments