From: Codeb Fan Date: Wed, 21 Aug 2013 07:48:55 +0000 (+0800) Subject: Add a test case for async_timeout in SimpleAsyncHTTPClient. X-Git-Tag: v3.2.0b1~52^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=65a4f8a77479101ab9ab84a0220f9d676f2bd1cd;p=thirdparty%2Ftornado.git Add a test case for async_timeout in SimpleAsyncHTTPClient. --- diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index 915376a71..fc681898c 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -396,3 +396,21 @@ class HostnameMappingTestCase(AsyncHTTPTestCase): response = self.wait() response.rethrow() self.assertEqual(response.body, b'Hello world!') + + +class HeavyloadAsyncHTTPClientTestCase(SimpleHTTPClientTestMixin, AsyncHTTPTestCase): + def create_client(self, **kwargs): + return SimpleAsyncHTTPClient(self.io_loop, force_instance=True, **kwargs) + + def test_heavyload_timeout(self): + with closing(self.create_client(max_clients=1)) as client: + client.fetch(self.get_url('/trigger?wake=false'), self.stop, request_timeout=10) + client.fetch(self.get_url('/hello'), self.stop, async_timeout=3) + response = self.wait() + + self.assertEqual(response.code, 599) + self.assertTrue(2.9 < response.request_time < 3.1, response.request_time) + self.assertEqual(str(response.error), "HTTP 599: Timeout") + self.triggers.popleft()() + +