]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Better way to force a getaddrinfo error.
authorBen Darnell <ben@bendarnell.com>
Thu, 14 Jun 2012 06:08:06 +0000 (23:08 -0700)
committerBen Darnell <ben@bendarnell.com>
Thu, 14 Jun 2012 06:08:06 +0000 (23:08 -0700)
This fixes the tests for users behind misbehaving DNS servers.

Closes #534.

tornado/test/iostream_test.py

index f62e4801c27b73d3ac040fa75f63ae1915d09220..4bb4f21cecf22fd95bb550d86bea951733b29eeb 100644 (file)
@@ -103,7 +103,11 @@ class TestIOStream(AsyncHTTPTestCase, LogTrapTestCase):
         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
         stream = IOStream(s, io_loop=self.io_loop)
         stream.set_close_callback(self.stop)
-        stream.connect(('adomainthatdoesntexist.asdf', 54321))
+        # To reliably generate a gaierror we use a malformed domain name
+        # instead of a name that's simply unlikely to exist (since
+        # opendns and some ISPs return bogus addresses for nonexistent
+        # domains instead of the proper error codes).
+        stream.connect(('an invalid domain', 54321))
         self.assertTrue(isinstance(stream.error, socket.gaierror), stream.error)
 
     def test_connection_closed(self):