#NEWLINE# def autopatcher( request , target , **kwargs ) : #NEWLINE# #INDENT# 'Patch and cleanup automatically. Wraps :py:func:`mock.patch`.' #NEWLINE# options = { #NEWLINE# #INDENT# 'autospec' : True , #NEWLINE# #UNINDENT# } #NEWLINE# options . update ( target ) #NEWLINE# patcher = mock . patch ( target , ** options ) #NEWLINE# obj = patcher . start ( ) #NEWLINE# request . addfinalizer ( patcher . stop ) #NEWLINE# return obj