def test_error_handler_status_message(): test_error = web.HTTPError(102, test_message, status_message=test_status) headers, response = test('GET', handler=web.HTTPErrorHandler, handler_args={'error': test_error}) assert response[0] == test_error.code assert response[1] == test_status assert response[2] == test_message
def test_error_handler(): test_error = web.HTTPError(102) headers, response = test('GET', handler=web.HTTPErrorHandler, handler_args={'error': test_error}) assert response[0] == test_error.code assert response[1] == web.status_messages[test_error.code] assert response[2] == str( test_error.code) + ' - ' + web.status_messages[test_error.code] + '\n'
def test_error_headers(): error_headers = web.HTTPHeaders() error_headers.set('Test', 'True') response, response_line, headers, body = test( web.DummyHandler, {'error': web.HTTPError(402, headers=error_headers)}) assert response_line == 'HTTP/1.1 402 Payment Required'.encode( web.http_encoding) assert headers.get('Test') == 'True'
def __init__(self, request, response, groups, error=web.HTTPError(500)): FakeHTTPHandler.__init__(self, request, response, groups) self.error = error
def check_continue(self): raise web.HTTPError(417)
def respond(self): self.response.headers.set('Test', 'True') raise web.HTTPError(402)
def test_http_error(): response, response_line, headers, body = test( web.DummyHandler, {'error': web.HTTPError(402)}) assert response_line == 'HTTP/1.1 402 Payment Required'.encode( web.http_encoding)