#NEWLINE# def create_patch( self , name , return_value = None ) : #NEWLINE# #INDENT# '\n        Easy workaround for having to nest mock.patch context managers\n        ' #NEWLINE# patcher = patch ( name ) #NEWLINE# thing = patcher . start ( ) #NEWLINE# if ( return_value is not None ) : #NEWLINE# #INDENT# thing . return_value = return_value #NEWLINE# #UNINDENT# self . addCleanup ( patcher . stop ) #NEWLINE# return thing