bpo-40275: Avoid importing socket in test.support (GH-19603)

* Move socket related functions from test.support to socket_helper.
* Import socket, nntplib and urllib.error lazily in transient_internet().
* Remove importing multiprocess.
This commit is contained in:
Serhiy Storchaka 2020-04-25 10:06:29 +03:00 committed by GitHub
parent 3c8a5b459d
commit 16994912c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 472 additions and 429 deletions

View file

@ -1,6 +1,7 @@
# test asynchat
from test import support
from test.support import socket_helper
import asynchat
import asyncore
@ -12,7 +13,7 @@ import time
import unittest
import unittest.mock
HOST = support.HOST
HOST = socket_helper.HOST
SERVER_QUIT = b'QUIT\n'
@ -25,7 +26,7 @@ class echo_server(threading.Thread):
threading.Thread.__init__(self)
self.event = event
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.port = support.bind_port(self.sock)
self.port = socket_helper.bind_port(self.sock)
# This will be set if the client wants us to wait before echoing
# data back.
self.start_resend_event = None