From: Grant Jenks Date: Thu, 22 Dec 2022 18:17:20 +0000 (-0800) Subject: Add test case for ThreadPoolExecutor usage X-Git-Tag: v6.3.0b1~9^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a60b0b2cfe54af382e00ef06e1b457c9e51dc459;p=thirdparty%2Ftornado.git Add test case for ThreadPoolExecutor usage --- 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!")