From: Ben Darnell Date: Sun, 20 May 2018 15:10:45 +0000 (-0400) Subject: test: Fix ResolveTimeoutTestCase X-Git-Tag: v5.1.0b1~10^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef034425b520bcf11f29d97c4355d7dcc9325e03;p=thirdparty%2Ftornado.git test: Fix ResolveTimeoutTestCase The dummy resolver used here was not correctly adapted for changes in netutil, and as a result the test was incorrect (it checked for TypeError instead of a timeout) and flaky (occasionally it would get a timeout error anyway). --- diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index 378c13d34..77a04ce4c 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -21,7 +21,7 @@ from tornado.locks import Event from tornado.log import gen_log from tornado.concurrent import Future from tornado.netutil import Resolver, bind_sockets -from tornado.simple_httpclient import SimpleAsyncHTTPClient, HTTPStreamClosedError +from tornado.simple_httpclient import SimpleAsyncHTTPClient, HTTPStreamClosedError, HTTPTimeoutError from tornado.test.httpclient_test import ChunkHandler, CountdownHandler, HelloWorldHandler, RedirectHandler # noqa: E501 from tornado.test import httpclient_test from tornado.testing import (AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, @@ -673,10 +673,11 @@ class HostnameMappingTestCase(AsyncHTTPTestCase): class ResolveTimeoutTestCase(AsyncHTTPTestCase): def setUp(self): - # Dummy Resolver subclass that never invokes its callback. + # Dummy Resolver subclass that never finishes. class BadResolver(Resolver): + @gen.coroutine def resolve(self, *args, **kwargs): - pass + yield Event().wait() super(ResolveTimeoutTestCase, self).setUp() self.http_client = SimpleAsyncHTTPClient( @@ -686,7 +687,7 @@ class ResolveTimeoutTestCase(AsyncHTTPTestCase): return Application([url("/hello", HelloWorldHandler), ]) def test_resolve_timeout(self): - with self.assertRaises(TypeError): + with self.assertRaises(HTTPTimeoutError): self.fetch('/hello', connect_timeout=0.1, raise_error=True)