#NEWLINE# def test_redirect_keep_session( ) : #NEWLINE# #INDENT# app = flask . Flask ( __name__ ) #NEWLINE# app . secret_key = 'testing' #NEWLINE# @ app . route ( '/' , methods = [ 'GET' , 'POST' ] ) #NEWLINE# def index( ) : #NEWLINE# #INDENT# if ( flask . request . method == 'POST' ) : #NEWLINE# #INDENT# return flask . redirect ( '/getsession' ) #NEWLINE# #UNINDENT# flask . session [ 'data' ] = 'foo' #NEWLINE# return 'index' #NEWLINE# #UNINDENT# @ app . route ( '/getsession' ) #NEWLINE# def get_session( ) : #NEWLINE# #INDENT# return flask . session . get ( 'data' , '<missing>' ) #NEWLINE# #UNINDENT# with app . test_client ( ) as c : #NEWLINE# #INDENT# rv = c . get ( '/getsession' ) #NEWLINE# assert ( rv . data == b'<missing>' ) #NEWLINE# rv = c . get ( '/' ) #NEWLINE# assert ( rv . data == b'index' ) #NEWLINE# assert ( flask . session . get ( 'data' ) == 'foo' ) #NEWLINE# rv = c . post ( '/' , data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , follow_redirects = True ) #NEWLINE# assert ( rv . data == b'foo' ) #NEWLINE# if ( not hasattr ( c , 'redirect_client' ) ) : #NEWLINE# #INDENT# assert ( flask . session . get ( 'data' ) == 'foo' ) #NEWLINE# #UNINDENT# rv = c . get ( '/getsession' ) #NEWLINE# assert ( rv . data == b'foo' )