From a60b0b2cfe54af382e00ef06e1b457c9e51dc459 Mon Sep 17 00:00:00 2001 From: Grant Jenks Date: Thu, 22 Dec 2022 10:17:20 -0800 Subject: [PATCH] Add test case for ThreadPoolExecutor usage --- tornado/test/wsgi_test.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tornado/test/wsgi_test.py b/tornado/test/wsgi_test.py index f98da5bd7..96fc294bc 100644 --- a/tornado/test/wsgi_test.py +++ b/tornado/test/wsgi_test.py @@ -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!") -- 2.47.3