コード例 #1
0
def test_HTTPExceptionMiddleware_exception_exc_info_none():
    class DummySys:
        def exc_info(self):
            return None

    def wsgi_response(environ, start_response):
        return start_response('200 OK', [], exc_info=None)

    def app(environ, start_response):
        raise HTTPException(None, wsgi_response)

    application = app
    m = HTTPExceptionMiddleware(application)
    environ = {}

    def start_response(status, headers, exc_info):
        pass

    try:
        from webob import exc
        old_sys = exc.sys
        sys = DummySys()
        res = m(environ, start_response)
        assert_equal(res, None)
    finally:
        exc.sys = old_sys
コード例 #2
0
ファイル: test_exc.py プロジェクト: witsch/webob
def test_HTTPExceptionMiddleware_ok():
    def app( environ, start_response ):
        return '123'
    application = app
    m = HTTPExceptionMiddleware(application)
    environ = {}
    start_response = None
    res = m( environ, start_response )
    assert_equal( res, '123' )
コード例 #3
0
ファイル: test_exc.py プロジェクト: witsch/webob
def test_HTTPExceptionMiddleware_exception():
    def wsgi_response( environ, start_response):
        return '123'
    def app( environ, start_response ):
        raise HTTPException( None, wsgi_response )
    application = app
    m = HTTPExceptionMiddleware(application)
    environ = {}
    start_response = None
    res = m( environ, start_response )
    assert_equal( res, '123' )