コード例 #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
ファイル: __init__.py プロジェクト: t-kenji/kallithea-mirror
 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
ファイル: __init__.py プロジェクト: t-kenji/kallithea-mirror
 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')