#NEWLINE# @ pytest . mark . skipif ( ( greenlet is None ) , reason = 'greenlet not installed' ) #NEWLINE# def test_greenlet_context_copying_api( ) : #NEWLINE# #INDENT# app = flask . Flask ( __name__ ) #NEWLINE# greenlets = [ ] #NEWLINE# @ app . route ( '/' ) #NEWLINE# def index( ) : #NEWLINE# #INDENT# reqctx = flask . _request_ctx_stack . top . copy ( ) #NEWLINE# @ flask . copy_current_request_context #NEWLINE# def g( ) : #NEWLINE# #INDENT# assert flask . request #NEWLINE# assert ( flask . current_app == app ) #NEWLINE# assert ( flask . request . path == '/' ) #NEWLINE# assert ( flask . request . args [ 'foo' ] == 'bar' ) #NEWLINE# return 42 #NEWLINE# #UNINDENT# greenlets . append ( greenlet ( g ) ) #NEWLINE# return 'Hello World!' #NEWLINE# #UNINDENT# rv = app . test_client ( ) . get ( '/?foo=bar' ) #NEWLINE# assert ( rv . data == b'Hello World!' ) #NEWLINE# result = greenlets [ 0 ] . run ( ) #NEWLINE# assert ( index == 42 )