]> 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>
Fri, 5 Jan 2018 14:04:44 +0000 (09:04 -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 02d57c5fb0d944409149ca7088bcc0061cd27a3b..451942d2800846c552a875fb15864fb5f1c88388 100644 (file)
@@ -327,7 +327,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 d83446e4286cc993680ac5ee3199a108795936fd..013c2ac25a82bb1e4e86ed6b4e7cea13e76fd081 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 74d04b6000b8f2ac61a3bf2793e1cfe27cc3098a..82a3b937326a64e70af6c6a991863c17ffd5b0e0 100644 (file)
@@ -423,7 +423,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):