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)])
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)])
def app( environ, start_response ): raise HTTPException( None, wsgi_response )
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')