#NEWLINE# def test_exit_library_context( self ) : #NEWLINE# #INDENT# def library_function( callback ) : #NEWLINE# #INDENT# callback = wrap ( callback ) #NEWLINE# with StackContext ( functools . partial ( self . context , 'library' ) ) : #NEWLINE# #INDENT# self . io_loop . add_callback ( functools . partial ( library_inner_callback , callback ) ) #NEWLINE# #UNINDENT# #UNINDENT# def library_inner_callback( callback ) : #NEWLINE# #INDENT# self . assertEqual ( self . active_contexts [ ( - 2 ) : ] , [ 'application' , 'library' ] ) #NEWLINE# callback ( ) #NEWLINE# #UNINDENT# def final_callback( ) : #NEWLINE# #INDENT# self . assertEqual ( self . active_contexts [ ( - 1 ) ] , 'application' ) #NEWLINE# self . stop ( ) #NEWLINE# #UNINDENT# with StackContext ( functools . partial ( self . context , 'application' ) ) : #NEWLINE# #INDENT# library_function ( final_callback ) #NEWLINE# #UNINDENT# self . wait ( )