mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
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:
parent
3c8a5b459d
commit
16994912c9
37 changed files with 472 additions and 429 deletions
|
@ -4,6 +4,7 @@ import threading
|
|||
import unittest
|
||||
import urllib.robotparser
|
||||
from test import support
|
||||
from test.support import socket_helper
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
|
||||
|
@ -312,7 +313,7 @@ class PasswordProtectedSiteTestCase(unittest.TestCase):
|
|||
# clear _opener global variable
|
||||
self.addCleanup(urllib.request.urlcleanup)
|
||||
|
||||
self.server = HTTPServer((support.HOST, 0), RobotHandler)
|
||||
self.server = HTTPServer((socket_helper.HOST, 0), RobotHandler)
|
||||
|
||||
self.t = threading.Thread(
|
||||
name='HTTPServer serving',
|
||||
|
@ -332,7 +333,7 @@ class PasswordProtectedSiteTestCase(unittest.TestCase):
|
|||
@support.reap_threads
|
||||
def testPasswordProtectedSite(self):
|
||||
addr = self.server.server_address
|
||||
url = 'http://' + support.HOST + ':' + str(addr[1])
|
||||
url = 'http://' + socket_helper.HOST + ':' + str(addr[1])
|
||||
robots_url = url + "/robots.txt"
|
||||
parser = urllib.robotparser.RobotFileParser()
|
||||
parser.set_url(url)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue