]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
test failure to set up curl http requests 1582/head
authorMin RK <benjaminrk@gmail.com>
Wed, 11 Nov 2015 13:32:00 +0000 (14:32 +0100)
committerMin RK <benjaminrk@gmail.com>
Wed, 11 Nov 2015 15:36:11 +0000 (16:36 +0100)
ensure that it doesn't starve free curl client list

tornado/test/curl_httpclient_test.py

index d06a7bd2ad93b2ecd83340a2f2f8d23b3fc4c990..097aec3e7cfcc9038a371a36e63da02460786000 100644 (file)
@@ -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)