]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
testing: Connect to 127.0.0.1 instead of localhost
authorBen Darnell <ben@bendarnell.com>
Sun, 5 Nov 2017 15:32:10 +0000 (10:32 -0500)
committerBen Darnell <ben@bendarnell.com>
Sun, 5 Nov 2017 15:32:10 +0000 (10:32 -0500)
The servers used in tests are only listening for ipv4, not ipv6
(to avoid spurious firewall prompts on macos). In what is apparently
a recent macos change, connecting to `localhost` when the ipv6 port
is unbound now incurs a 200ms delay, slowing a full test run down
by a factor of 20.

tornado/test/simple_httpclient_test.py
tornado/test/web_test.py
tornado/testing.py

index 309678efdc4bcc6a4ac8dea59dfef9a0404c2c58..f8d1a0546203bdcad5dedad30cc7543e40a12f76 100644 (file)
@@ -326,7 +326,7 @@ class SimpleHTTPClientTestMixin(object):
         self.assertNotIn("Content-Length", response.headers)
 
     def test_host_header(self):
-        host_re = re.compile(b"^localhost:[0-9]+$")
+        host_re = re.compile(b"^127.0.0.1:[0-9]+$")
         response = self.fetch("/host_echo")
         self.assertTrue(host_re.match(response.body))
 
index 7c33fd9015ac49d027820f7a58d8513fbd4f9d0e..7e3ac7c258a71e6f108b380a687714ef53bd6e51 100644 (file)
@@ -356,7 +356,7 @@ class AuthRedirectTest(WebTestCase):
         response = self.wait()
         self.assertEqual(response.code, 302)
         self.assertTrue(re.match(
-            'http://example.com/login\?next=http%3A%2F%2Flocalhost%3A[0-9]+%2Fabsolute',
+            'http://example.com/login\?next=http%3A%2F%2F127.0.0.1%3A[0-9]+%2Fabsolute',
             response.headers['Location']), response.headers['Location'])
 
 
index b79ba59283711082b52c75e4bd41c57e379ea43d..86d4b57441aed997067cb202c9be6ecf447c20d3 100644 (file)
@@ -407,7 +407,7 @@ class AsyncHTTPTestCase(AsyncTestCase):
 
     def get_url(self, path):
         """Returns an absolute url for the given path on the test server."""
-        return '%s://localhost:%s%s' % (self.get_protocol(),
+        return '%s://127.0.0.1:%s%s' % (self.get_protocol(),
                                         self.get_http_port(), path)
 
     def tearDown(self):