From aabad7a1a04e510e06e141c96810ac5d58dbc1ab Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 11 Nov 2015 14:32:00 +0100 Subject: [PATCH] test failure to set up curl http requests ensure that it doesn't starve free curl client list --- tornado/test/curl_httpclient_test.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tornado/test/curl_httpclient_test.py b/tornado/test/curl_httpclient_test.py index d06a7bd2a..097aec3e7 100644 --- a/tornado/test/curl_httpclient_test.py +++ b/tornado/test/curl_httpclient_test.py @@ -1,3 +1,4 @@ +# coding: utf-8 from __future__ import absolute_import, division, print_function, with_statement from hashlib import md5 @@ -83,8 +84,7 @@ class CustomFailReasonHandler(RequestHandler): class CurlHTTPClientTestCase(AsyncHTTPTestCase): def setUp(self): super(CurlHTTPClientTestCase, self).setUp() - self.http_client = CurlAsyncHTTPClient(self.io_loop, - defaults=dict(allow_ipv6=False)) + self.http_client = self.create_client() def get_app(self): return Application([ @@ -93,6 +93,11 @@ class CurlHTTPClientTestCase(AsyncHTTPTestCase): ('/custom_fail_reason', CustomFailReasonHandler), ]) + def create_client(self, **kwargs): + return CurlAsyncHTTPClient(self.io_loop, force_instance=True, + defaults=dict(allow_ipv6=False), + **kwargs) + def test_prepare_curl_callback_stack_context(self): exc_info = [] @@ -122,3 +127,8 @@ class CurlHTTPClientTestCase(AsyncHTTPTestCase): response = self.fetch('/custom_fail_reason') self.assertEqual(str(response.error), "HTTP 400: Custom reason") + def test_failed_setup(self): + self.http_client = self.create_client(max_clients=1) + for i in range(5): + response = self.fetch(u'/ユニコード') + self.assertIsNot(response.error, None) -- 2.47.2