예제 #1
0
def test_HTTPException():
    _called = []
    _result = object()

    def _response(environ, start_response):
        _called.append((environ, start_response))
        return _result

    environ = {}
    start_response = object()
    exc = HTTPException('testing', _response)
    ok_(exc.wsgi_response is _response)
    ok_(exc.exception is exc)
    result = exc(environ, start_response)
    ok_(result is result)
    assert_equal(_called, [(environ, start_response)])
예제 #2
0
파일: test_exc.py 프로젝트: witsch/webob
def test_HTTPException():
    import warnings
    _called = []
    _result = object()
    def _response(environ, start_response):
        _called.append((environ, start_response))
        return _result
    environ = {}
    start_response = object()
    exc = HTTPException('testing', _response)
    ok_(exc.wsgi_response is _response)
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        assert(exc.exception is exc)
        assert(len(w) == 1)
    result = exc(environ, start_response)
    ok_(result is result)
    assert_equal(_called, [(environ, start_response)])
예제 #3
0
파일: test_exc.py 프로젝트: witsch/webob
 def app( environ, start_response ):
     raise HTTPException( None, wsgi_response )
예제 #4
0
 def __init__(self, message=None, retid=None, code=None):
     HTTPException.__init__(self, message, self)
     Response.__init__(self,
                       json_body=dict(id=retid, result=None, error=message),
                       status=code,
                       content_type='application/json')
예제 #5
0
 def __init__(self, message=None, retid=None, code=None):
     HTTPException.__init__(self, message, self)
     Response.__init__(self,
                       json_body=dict(id=retid, result=None, error=message),
                       status=code,
                       content_type='application/json')