#NEWLINE# def test_dict_context_manager( self ) : #NEWLINE# #INDENT# foo = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# with patch . dict ( foo , { #NEWLINE# #INDENT# 'a' : 'b' , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertEqual ( self , { #NEWLINE# #INDENT# 'a' : 'b' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# self . assertEqual ( foo , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# with self . assertRaises ( NameError ) : #NEWLINE# #INDENT# with patch . dict ( foo , { #NEWLINE# #INDENT# 'a' : 'b' , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertEqual ( foo , { #NEWLINE# #INDENT# 'a' : 'b' , #NEWLINE# #UNINDENT# } ) #NEWLINE# raise NameError ( 'Konrad' ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( foo , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } )