Python tornado.wsgi.WSGIApplication() Examples

The following are 25 code examples of tornado.wsgi.WSGIApplication(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tornado.wsgi , or try the search function .
Example #1
Source File: wsgi_test.py    From tornado-zh with MIT License 6 votes vote down vote up
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # 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),
        ]))) 
Example #2
Source File: wsgi_test.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # 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),
        ]))) 
Example #3
Source File: wsgi_test.py    From viewfinder with Apache License 2.0 6 votes vote down vote up
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # 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),
        ]))) 
Example #4
Source File: wsgi_test.py    From honeything with GNU General Public License v3.0 6 votes vote down vote up
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # 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),
                        ]))) 
Example #5
Source File: wsgi_test.py    From pySINDy with MIT License 6 votes vote down vote up
def wrap_web_tests_application():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        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 
Example #6
Source File: wsgi_test.py    From viewfinder with Apache License 2.0 6 votes vote down vote up
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # 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),
        ]))) 
Example #7
Source File: wsgi_test.py    From tornado-zh with MIT License 6 votes vote down vote up
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # 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),
        ]))) 
Example #8
Source File: wsgi_test.py    From teleport with Apache License 2.0 6 votes vote down vote up
def wrap_web_tests_application():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        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 
Example #9
Source File: wsgi_test.py    From viewfinder with Apache License 2.0 5 votes vote down vote up
def get_app(self):
        return WSGIContainer(validator(WSGIApplication(self.get_handlers()))) 
Example #10
Source File: wsgi_test.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def wrap_web_tests_application():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIApplicationWrappedTest(cls):
            def get_app(self):
                self.app = WSGIApplication(self.get_handlers(),
                                           **self.get_app_kwargs())
                return WSGIContainer(validator(self.app))
        result["WSGIApplication_" + cls.__name__] = WSGIApplicationWrappedTest
    return result 
Example #11
Source File: wsgi_test.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def get_app(self):
        return WSGIContainer(validator(WSGIApplication(self.get_handlers()))) 
Example #12
Source File: wsgi_test.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def test_types(self):
        headers = {"Cookie": "foo=bar"}
        response = self.fetch("/typecheck?foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

        response = self.fetch("/typecheck", method="POST", body="foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

# This is kind of hacky, but run some of the HTTPServer tests through
# WSGIContainer and WSGIApplication to make sure everything survives
# repeated disassembly and reassembly. 
Example #13
Source File: wsgi_test.py    From honeything with GNU General Public License v3.0 5 votes vote down vote up
def get_app(self):
        return WSGIContainer(validator(WSGIApplication(self.get_handlers()))) 
Example #14
Source File: wsgi_test.py    From honeything with GNU General Public License v3.0 5 votes vote down vote up
def test_types(self):
        headers = {"Cookie": "foo=bar"}
        response = self.fetch("/typecheck?foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

        response = self.fetch("/typecheck", method="POST", body="foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

# This is kind of hacky, but run some of the HTTPServer tests through
# WSGIContainer and WSGIApplication to make sure everything survives
# repeated disassembly and reassembly. 
Example #15
Source File: wsgi_test.py    From pySINDy with MIT License 5 votes vote down vote up
def test_types(self):
        headers = {"Cookie": "foo=bar"}
        response = self.fetch("/typecheck?foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

        response = self.fetch("/typecheck", method="POST", body="foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})


# This is kind of hacky, but run some of the HTTPServer and web tests
# through WSGIContainer and WSGIApplication to make sure everything
# survives repeated disassembly and reassembly. 
Example #16
Source File: wsgi_test.py    From teleport with Apache License 2.0 5 votes vote down vote up
def test_types(self):
        headers = {"Cookie": "foo=bar"}
        response = self.fetch("/typecheck?foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

        response = self.fetch("/typecheck", method="POST", body="foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})


# This is kind of hacky, but run some of the HTTPServer and web tests
# through WSGIContainer and WSGIApplication to make sure everything
# survives repeated disassembly and reassembly. 
Example #17
Source File: wsgi_test.py    From viewfinder with Apache License 2.0 5 votes vote down vote up
def wrap_web_tests():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIWrappedTest(cls):
            def get_app(self):
                self.app = WSGIApplication(self.get_handlers(),
                                           **self.get_app_kwargs())
                return WSGIContainer(validator(self.app))
        result["WSGIWrapped_" + cls.__name__] = WSGIWrappedTest
    return result 
Example #18
Source File: wsgi_test.py    From viewfinder with Apache License 2.0 5 votes vote down vote up
def wrap_web_tests():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIWrappedTest(cls):
            def get_app(self):
                self.app = WSGIApplication(self.get_handlers(),
                                           **self.get_app_kwargs())
                return WSGIContainer(validator(self.app))
        result["WSGIWrapped_" + cls.__name__] = WSGIWrappedTest
    return result 
Example #19
Source File: wsgi_test.py    From viewfinder with Apache License 2.0 5 votes vote down vote up
def get_app(self):
        return WSGIContainer(validator(WSGIApplication(self.get_handlers()))) 
Example #20
Source File: wsgi_test.py    From viewfinder with Apache License 2.0 5 votes vote down vote up
def test_types(self):
        headers = {"Cookie": "foo=bar"}
        response = self.fetch("/typecheck?foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

        response = self.fetch("/typecheck", method="POST", body="foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

# This is kind of hacky, but run some of the HTTPServer tests through
# WSGIContainer and WSGIApplication to make sure everything survives
# repeated disassembly and reassembly. 
Example #21
Source File: wsgi_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def wrap_web_tests_application():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIApplicationWrappedTest(cls):
            def get_app(self):
                self.app = WSGIApplication(self.get_handlers(),
                                           **self.get_app_kwargs())
                return WSGIContainer(validator(self.app))
        result["WSGIApplication_" + cls.__name__] = WSGIApplicationWrappedTest
    return result 
Example #22
Source File: wsgi_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def get_app(self):
        return WSGIContainer(validator(WSGIApplication(self.get_handlers()))) 
Example #23
Source File: wsgi_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def wrap_web_tests_application():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIApplicationWrappedTest(cls):
            def get_app(self):
                self.app = WSGIApplication(self.get_handlers(),
                                           **self.get_app_kwargs())
                return WSGIContainer(validator(self.app))
        result["WSGIApplication_" + cls.__name__] = WSGIApplicationWrappedTest
    return result 
Example #24
Source File: wsgi_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def get_app(self):
        return WSGIContainer(validator(WSGIApplication(self.get_handlers()))) 
Example #25
Source File: wsgi_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def test_types(self):
        headers = {"Cookie": "foo=bar"}
        response = self.fetch("/typecheck?foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

        response = self.fetch("/typecheck", method="POST", body="foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

# This is kind of hacky, but run some of the HTTPServer tests through
# WSGIContainer and WSGIApplication to make sure everything survives
# repeated disassembly and reassembly.