def test_redapp():
 saved = []
 def saveit(status, headers, exc_info=None):
  saved.append((status, headers))
 def redapp(environ, start_response):
  raise HTTPFound('/bing/foo')
 app = HTTPExceptionHandler(redapp)
 result = list(app({'HTTP_ACCEPT': 'text/html'}, saveit))
 assert ('<a href="/bing/foo">' in result[0])
 assert ('302 Found' == saved[0][0])
 if six.PY3:
  assert ('text/html; charset=utf8' == header_value(saved[0][1], 'content-type'))
 else:
  assert ('text/html' == header_value(saved[0][1], 'content-type'))
 assert ('/bing/foo' == header_value(saved[0][1], 'location'))
 result = list(app({'HTTP_ACCEPT': 'text/plain'}, saveit))
 assert ('text/plain; charset=utf8' == header_value(saved[1][1], 'content-type'))
 assert ('/bing/foo' == header_value(saved[1][1], 'location'))

def test_redapp ( ) : saved = [ ] def saveit ( status , headers , exc_info = None ) : saved . append ( ( status , headers ) ) def redapp ( environ , start_response ) : raise HTTPFound ( '/bing/foo' ) app = HTTPExceptionHandler ( redapp ) result = list ( app ( { 'HTTP_ACCEPT' : 'text/html' } , saveit ) ) assert ( '<a href="/bing/foo">' in result [ 0 ] ) assert ( '302 Found' == saved [ 0 ] [ 0 ] ) if six . PY3 : assert ( 'text/html; charset=utf8' == header_value ( saved [ 0 ] [ 1 ] , 'content-type' ) ) else : assert ( 'text/html' == header_value ( saved [ 0 ] [ 1 ] , 'content-type' ) ) assert ( '/bing/foo' == header_value ( saved [ 0 ] [ 1 ] , 'location' ) ) result = list ( app ( { 'HTTP_ACCEPT' : 'text/plain' } , saveit ) ) assert ( 'text/plain; charset=utf8' == header_value ( saved [ 1 ] [ 1 ] , 'content-type' ) ) assert ( '/bing/foo' == header_value ( saved [ 1 ] [ 1 ] , 'location' ) )
check that redirect returns the correct .