diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-04-25 07:06:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 07:06:29 (GMT) |
commit | 16994912c93e8e5db7365d48b75d67d3f70dd7b2 (patch) | |
tree | 248f177a93676406af6d6ae977bed868aa2d1a34 /Lib/test/test_httplib.py | |
parent | 3c8a5b459d68b4337776ada1e04f5b33f90a2275 (diff) | |
download | cpython-16994912c93e8e5db7365d48b75d67d3f70dd7b2.zip cpython-16994912c93e8e5db7365d48b75d67d3f70dd7b2.tar.gz cpython-16994912c93e8e5db7365d48b75d67d3f70dd7b2.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r-- | Lib/test/test_httplib.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 77d4335..6b7a9de 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -13,6 +13,7 @@ import unittest TestCase = unittest.TestCase from test import support +from test.support import socket_helper here = os.path.dirname(__file__) # Self-signed cert file for 'localhost' @@ -42,7 +43,7 @@ last_chunk_extended = "0" + chunk_extension + "\r\n" trailers = "X-Dummy: foo\r\nX-Dumm2: bar\r\n" chunked_end = "\r\n" -HOST = support.HOST +HOST = socket_helper.HOST class FakeSocket: def __init__(self, text, fileclass=io.BytesIO, host=None, port=None): @@ -1463,8 +1464,8 @@ class OfflineTest(TestCase): class SourceAddressTest(TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.port = support.bind_port(self.serv) - self.source_port = support.find_unused_port() + self.port = socket_helper.bind_port(self.serv) + self.source_port = socket_helper.find_unused_port() self.serv.listen() self.conn = None @@ -1496,7 +1497,7 @@ class TimeoutTest(TestCase): def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - TimeoutTest.PORT = support.bind_port(self.serv) + TimeoutTest.PORT = socket_helper.bind_port(self.serv) self.serv.listen() def tearDown(self): |