bpo-40275: Avoid importing socket in test.support by serhiy-storchaka · Pull Request #19603 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 71 additions & 59 deletions Doc/library/test.rst
9 changes: 5 additions & 4 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import test.support
import test.support.script_helper
from test import support
from test.support import socket_helper


# Skip tests if _multiprocessing wasn't built.
Expand Down Expand Up @@ -2928,7 +2929,7 @@ def test_remote(self):
authkey = os.urandom(32)

manager = QueueManager(
address=(test.support.HOST, 0), authkey=authkey, serializer=SERIALIZER
address=(socket_helper.HOST, 0), authkey=authkey, serializer=SERIALIZER
)
manager.start()
self.addCleanup(manager.shutdown)
Expand Down Expand Up @@ -2965,7 +2966,7 @@ def _putter(cls, address, authkey):
def test_rapid_restart(self):
authkey = os.urandom(32)
manager = QueueManager(
address=(test.support.HOST, 0), authkey=authkey, serializer=SERIALIZER)
address=(socket_helper.HOST, 0), authkey=authkey, serializer=SERIALIZER)
try:
srvr = manager.get_server()
addr = srvr.address
Expand Down Expand Up @@ -3455,7 +3456,7 @@ def _listener(cls, conn, families):
new_conn.close()
l.close()

l = socket.create_server((test.support.HOST, 0))
l = socket.create_server((socket_helper.HOST, 0))
conn.send(l.getsockname())
new_conn, addr = l.accept()
conn.send(new_conn)
Expand Down Expand Up @@ -4581,7 +4582,7 @@ def _child_test_wait_socket(cls, address, slow):

def test_wait_socket(self, slow=False):
from multiprocessing.connection import wait
l = socket.create_server((test.support.HOST, 0))
l = socket.create_server((socket_helper.HOST, 0))
addr = l.getsockname()
readers = []
procs = []
Expand Down
5 changes: 3 additions & 2 deletions Lib/test/eintrdata/eintr_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import unittest

from test import support
from test.support import socket_helper

@contextlib.contextmanager
def kill_on_error(proc):
Expand Down Expand Up @@ -283,14 +284,14 @@ def test_sendmsg(self):
self._test_send(lambda sock, data: sock.sendmsg([data]))

def test_accept(self):
sock = socket.create_server((support.HOST, 0))
sock = socket.create_server((socket_helper.HOST, 0))
self.addCleanup(sock.close)
port = sock.getsockname()[1]

code = '\n'.join((
'import socket, time',
'',
'host = %r' % support.HOST,
'host = %r' % socket_helper.HOST,
'port = %s' % port,
'sleep_time = %r' % self.sleep_time,
'',
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/ssl_servers.py
Loading