from tornado.escape import json_decode
from tornado.test.httpserver_test import TypeCheckHandler
+from tornado.test.util import ignore_deprecation
from tornado.testing import AsyncHTTPTestCase
from tornado.web import RequestHandler, Application
from tornado.wsgi import WSGIApplication, WSGIContainer, WSGIAdapter
self.assertEqual(response.body, b"Hello world!")
-class WSGIApplicationTest(AsyncHTTPTestCase):
+class WSGIAdapterTest(AsyncHTTPTestCase):
def get_app(self):
class HelloHandler(RequestHandler):
def get(self):
# another thread instead of using our own WSGIContainer, but this
# fits better in our async testing framework and the wsgiref
# validator should keep us honest
- return WSGIContainer(validator(WSGIApplication([
- ("/", HelloHandler),
- ("/path/(.*)", PathQuotingHandler),
- ("/typecheck", TypeCheckHandler),
- ])))
+ with ignore_deprecation():
+ return WSGIContainer(validator(WSGIAdapter(
+ Application([
+ ("/", HelloHandler),
+ ("/path/(.*)", PathQuotingHandler),
+ ("/typecheck", TypeCheckHandler),
+ ]))))
def test_simple(self):
response = self.fetch("/")
# survives repeated disassembly and reassembly.
class WSGIConnectionTest(httpserver_test.HTTPConnectionTest):
def get_app(self):
- return WSGIContainer(validator(WSGIApplication(self.get_handlers())))
+ with ignore_deprecation():
+ return WSGIContainer(validator(WSGIAdapter(Application(self.get_handlers()))))
def wrap_web_tests_application():
result = {}
for cls in web_test.wsgi_safe_tests:
- class WSGIApplicationWrappedTest(cls): # type: ignore
- def get_app(self):
- self.app = WSGIApplication(self.get_handlers(),
- **self.get_app_kwargs())
- return WSGIContainer(validator(self.app))
- result["WSGIApplication_" + cls.__name__] = WSGIApplicationWrappedTest
+ def class_factory():
+ class WSGIApplicationWrappedTest(cls): # type: ignore
+ def setUp(self):
+ self.warning_catcher = ignore_deprecation()
+ self.warning_catcher.__enter__()
+ super(WSGIApplicationWrappedTest, self).setUp()
+
+ def tearDown(self):
+ super(WSGIApplicationWrappedTest, self).tearDown()
+ self.warning_catcher.__exit__(None, None, None)
+
+ def get_app(self):
+ self.app = WSGIApplication(self.get_handlers(),
+ **self.get_app_kwargs())
+ return WSGIContainer(validator(self.app))
+ result["WSGIApplication_" + cls.__name__] = class_factory()
return result
def get_app(self):
self.app = Application(self.get_handlers(),
**self.get_app_kwargs())
- return WSGIContainer(validator(WSGIAdapter(self.app)))
+ with ignore_deprecation():
+ return WSGIContainer(validator(WSGIAdapter(self.app)))
result["WSGIAdapter_" + cls.__name__] = WSGIAdapterWrappedTest
return result
import sys
from io import BytesIO
import tornado
+import warnings
from tornado.concurrent import Future
from tornado import escape
.. deprecated:: 4.0
Use a regular `.Application` and wrap it in `WSGIAdapter` instead.
+ This class will be removed in Tornado 6.0.
"""
def __call__(self, environ, start_response):
return WSGIAdapter(self)(environ, start_response)
`tornado.auth` or `tornado.websocket` modules.
.. versionadded:: 4.0
+
+ .. deprecated:: 5.1
+
+ This class is deprecated and will be removed in Tornado 6.0.
+ Use Tornado's `.HTTPServer` instead of a WSGI container.
"""
def __init__(self, application):
+ warnings.warn("WSGIAdapter is deprecated, use Tornado's HTTPServer instead",
+ DeprecationWarning)
if isinstance(application, WSGIApplication):
self.application = lambda request: web.Application.__call__(
application, request)