From ca378b9c9979dcbe00d2407fed7684006ddfa8bb Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 17 Jun 2012 22:57:23 -0700 Subject: [PATCH] Run some (synchronous) web.py tests via wsgi too. There's probably a more principled way to do this, but for now just port this batch of tests, which would have caught the add_header bug from the previous commit, and uncovered an encoding problem on python 3. --- tornado/test/web_test.py | 43 +++++++++++++++++++++++++-------------- tornado/test/wsgi_test.py | 7 +++++++ tornado/wsgi.py | 30 +++++++++++++++++++++++---- 3 files changed, 61 insertions(+), 19 deletions(-) diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 37a098b36..ad4173365 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -447,10 +447,15 @@ class HeaderInjectionHandler(RequestHandler): raise -class WebTest(AsyncHTTPTestCase, LogTrapTestCase): +# This test is shared with wsgi_test.py +class WSGISafeWebTest(AsyncHTTPTestCase, LogTrapTestCase): COOKIE_SECRET = "WebTest.COOKIE_SECRET" def get_app(self): + self.app = Application(self.get_handlers(), **self.get_app_kwargs()) + return self.app + + def get_app_kwargs(self): loader = DictLoader({ "linkify.html": "{% module linkify(message) %}", "page.html": """\ @@ -463,6 +468,11 @@ class WebTest(AsyncHTTPTestCase, LogTrapTestCase): {{ set_resources(embedded_css=".entry { margin-bottom: 1em; }", embedded_javascript="js_embed()", css_files=["/base.css", "/foo.css"], javascript_files="/common.js", html_head="", html_body='