summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-08-21 22:39:46 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-08-21 22:39:46 (GMT)
commit78254dc6fc71d28f70c52dd70c0bc3e14ae7d0c2 (patch)
treea6557070a42e14875f2f7c0dc4cd3f711f44d674
parent4203570d01e8752288a5aed95f5a832f15a5b548 (diff)
downloadcpython-78254dc6fc71d28f70c52dd70c0bc3e14ae7d0c2.zip
cpython-78254dc6fc71d28f70c52dd70c0bc3e14ae7d0c2.tar.gz
cpython-78254dc6fc71d28f70c52dd70c0bc3e14ae7d0c2.tar.bz2
Issue #18792: Use "127.0.0.1" or "::1" instead of "localhost" as much as possible, since "localhost" goes through a DNS lookup under recent Windows versions.
-rw-r--r--Lib/test/test_asyncore.py3
-rw-r--r--Lib/test/test_ftplib.py8
-rw-r--r--Lib/test/test_multiprocessing.py4
-rw-r--r--Lib/test/test_support.py7
-rw-r--r--Misc/NEWS4
5 files changed, 17 insertions, 9 deletions
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
index 134470f..20eceb6 100644
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -10,7 +10,7 @@ import errno
import struct
from test import test_support
-from test.test_support import TESTFN, run_unittest, unlink
+from test.test_support import TESTFN, run_unittest, unlink, HOST
from StringIO import StringIO
try:
@@ -18,7 +18,6 @@ try:
except ImportError:
threading = None
-HOST = test_support.HOST
class dummysocket:
def __init__(self):
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
index 535bc49..e6aaca5 100644
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -17,7 +17,7 @@ except ImportError:
from unittest import TestCase
from test import test_support
-from test.test_support import HOST
+from test.test_support import HOST, HOSTv6
threading = test_support.import_module('threading')
@@ -562,7 +562,7 @@ class TestFTPClass(TestCase):
class TestIPv6Environment(TestCase):
def setUp(self):
- self.server = DummyFTPServer((HOST, 0), af=socket.AF_INET6)
+ self.server = DummyFTPServer((HOSTv6, 0), af=socket.AF_INET6)
self.server.start()
self.client = ftplib.FTP()
self.client.connect(self.server.host, self.server.port)
@@ -713,7 +713,7 @@ class TestTimeouts(TestCase):
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
- ftp = ftplib.FTP("localhost")
+ ftp = ftplib.FTP(HOST)
finally:
socket.setdefaulttimeout(None)
self.assertEqual(ftp.sock.gettimeout(), 30)
@@ -725,7 +725,7 @@ class TestTimeouts(TestCase):
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
- ftp = ftplib.FTP("localhost", timeout=None)
+ ftp = ftplib.FTP(HOST, timeout=None)
finally:
socket.setdefaulttimeout(None)
self.assertTrue(ftp.sock.gettimeout() is None)
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 5ffe759..925f39d 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1385,7 +1385,7 @@ class _TestRemoteManager(BaseTestCase):
authkey = os.urandom(32)
manager = QueueManager(
- address=('localhost', 0), authkey=authkey, serializer=SERIALIZER
+ address=(test.test_support.HOST, 0), authkey=authkey, serializer=SERIALIZER
)
manager.start()
@@ -1423,7 +1423,7 @@ class _TestManagerRestart(BaseTestCase):
def test_rapid_restart(self):
authkey = os.urandom(32)
manager = QueueManager(
- address=('localhost', 0), authkey=authkey, serializer=SERIALIZER)
+ address=(test.test_support.HOST, 0), authkey=authkey, serializer=SERIALIZER)
srvr = manager.get_server()
addr = srvr.address
# Close the connection.Listener socket which gets opened as a part
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index fe5a4f3..be867bd 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -290,7 +290,12 @@ def requires(resource, msg=None):
msg = "Use of the `%s' resource not enabled" % resource
raise ResourceDenied(msg)
-HOST = 'localhost'
+
+# Don't use "localhost", since resolving it uses the DNS under recent
+# Windows versions (see issue #18792).
+HOST = "127.0.0.1"
+HOSTv6 = "::1"
+
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
"""Returns an unused port that should be suitable for binding. This is
diff --git a/Misc/NEWS b/Misc/NEWS
index 67853e4..318a974 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -191,6 +191,10 @@ IDLE
Tests
-----
+- Issue #18792: Use "127.0.0.1" or "::1" instead of "localhost" as much as
+ possible, since "localhost" goes through a DNS lookup under recent Windows
+ versions.
+
- Issue #18357: add tests for dictview set difference.
Patch by Fraser Tweedale.