Example #1
0
    def run(self):
        # FIXME: All files under current directory
        files = ['index.wsgi']

        # XXX:
        # when django template renders `environ` in its 500 page, it will
        # try to call `environ['werkzeug.server.shutdown'` and cause the
        # server exit unexpectedly.
        # See: https://docs.djangoproject.com/en/dev/ref/templates/api/#variables-and-lookups
        def wrap(app):
            def _(environ, start_response):
                try:
                    del environ['werkzeug.server.shutdown']
                except KeyError:
                    pass
                return app(environ, start_response)

            return _

        if 'WERKZEUG_RUN_MAIN' in os.environ:
            os.environ['sae.run_main'] = '1'

        self.application = _channel_wrapper(self.application)
        from werkzeug.serving import run_simple
        run_simple(self.conf.host,
                   self.conf.port,
                   wrap(self.application),
                   use_reloader=True,
                   use_debugger=True,
                   extra_files=files,
                   static_files=self.static_files)
Example #2
0
    def run(self):
        # FIXME: All files under current directory
        files = ["index.wsgi"]

        # XXX:
        # when django template renders `environ` in its 500 page, it will
        # try to call `environ['werkzeug.server.shutdown'` and cause the
        # server exit unexpectedly.
        # See: https://docs.djangoproject.com/en/dev/ref/templates/api/#variables-and-lookups
        def wrap(app):
            def _(environ, start_response):
                try:
                    del environ["werkzeug.server.shutdown"]
                except KeyError:
                    pass
                return app(environ, start_response)

            return _

        if "WERKZEUG_RUN_MAIN" in os.environ:
            os.environ["sae.run_main"] = "1"

        self.application = _channel_wrapper(self.application)
        from werkzeug.serving import run_simple

        run_simple(
            self.conf.host,
            self.conf.port,
            wrap(self.application),
            use_reloader=True,
            use_debugger=True,
            extra_files=files,
            static_files=self.static_files,
        )
Example #3
0
    def test(self):
        files = ['index.wsgi']

        # XXX:
        # when django template renders `environ` in its 500 page, it will
        # try to call `environ['werkzeug.server.shutdown'` and cause the
        # server exit unexpectedly.
        # See: https://docs.djangoproject.com/en/dev/ref/templates/api/#variables-and-lookups
        def wrap(app):
            def _(environ, start_response):
                try:
                    del environ['werkzeug.server.shutdown']
                except KeyError:
                    pass
                return app(environ, start_response)
            return _

        if 'WERKZEUG_RUN_MAIN' in os.environ:
            os.environ['sae.run_main'] = '1'

        self.application = _channel_wrapper(self.application)
        # from werkzeug.serving import run_simple
        # run_simple(self.conf.host, self.conf.port,
        #            wrap(self.application),
        #            use_reloader = True,
        #            use_debugger = True,
        #            extra_files = files,
        #            static_files = self.static_files)
        print "test begin"

        from werkzeug.test import Client
        from werkzeug.wrappers import BaseResponse
        c = Client(wrap(self.application), BaseResponse)

        # test login page
        resp = c.get('/login?next=%2F')
        print resp.status_code
        assert resp.status_code == 200

        print "test end"