]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add test case for ThreadPoolExecutor usage
authorGrant Jenks <grant.jenks@gmail.com>
Thu, 22 Dec 2022 18:17:20 +0000 (10:17 -0800)
committerBen Darnell <ben@bendarnell.com>
Thu, 16 Feb 2023 20:37:12 +0000 (20:37 +0000)
tornado/test/wsgi_test.py

index f98da5bd73606a15996ce93087312976d3edcc95..96fc294bcffd3da0b5806622493591ef8b70a1af 100644 (file)
@@ -1,20 +1,34 @@
+import concurrent.futures
+
 from wsgiref.validate import validator
 
 from tornado.testing import AsyncHTTPTestCase
 from tornado.wsgi import WSGIContainer
 
 
-class WSGIContainerTest(AsyncHTTPTestCase):
-    # TODO: Now that WSGIAdapter is gone, this is a pretty weak test.
+class WSGIAppMixin:
     def wsgi_app(self, environ, start_response):
         status = "200 OK"
         response_headers = [("Content-Type", "text/plain")]
         start_response(status, response_headers)
         return [b"Hello world!"]
 
+
+class WSGIContainerTest(WSGIAppMixin, AsyncHTTPTestCase):
+    # TODO: Now that WSGIAdapter is gone, this is a pretty weak test.
     def get_app(self):
         return WSGIContainer(validator(self.wsgi_app))
 
     def test_simple(self):
         response = self.fetch("/")
         self.assertEqual(response.body, b"Hello world!")
+
+
+class WSGIContainerThreadPoolTest(WSGIAppMixin, AsyncHTTPTestCase):
+    def get_app(self):
+        executor = concurrent.futures.ThreadPoolExecutor()
+        return WSGIContainer(validator(self.wsgi_app), executor)
+
+    def test_simple(self):
+        response = self.fetch("/")
+        self.assertEqual(response.body, b"Hello world!")