#NEWLINE# def test_null_session( self ) : #NEWLINE# #INDENT# app = flask . Flask ( __name__ ) #NEWLINE# Session ( self ) #NEWLINE# def expect_exception( f , * args , **kwargs ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# f ( * args , ** kwargs ) #NEWLINE# #UNINDENT# except RuntimeError as e : #NEWLINE# #INDENT# self . assertTrue ( ( e . args and ( 'session is unavailable' in e . args [ 0 ] ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertTrue ( False , 'expected exception' ) #NEWLINE# #UNINDENT# #UNINDENT# with app . test_request_context ( ) : #NEWLINE# #INDENT# self . assertTrue ( ( flask . session . get ( 'missing_key' ) is None ) ) #NEWLINE# expect_exception ( flask . session . __setitem__ , 'foo' , 42 ) #NEWLINE# expect_exception ( flask . session . pop , 'foo' )