def initializer_mock(request, cls):
 _patch = patch.object(cls, '__init__', return_value=None)
 request.addfinalizer(_patch.stop)
 return _patch.start()

def initializer_mock ( request , cls ) : _patch = patch . object ( cls , '__init__' , return_value = None ) request . addfinalizer ( _patch . stop ) return _patch . start ( )
return a mock for the __init__ method on *cls* where the patch is reversed after pytest uses it .