def function_mock(request, q_function_name, **kwargs):
 _patch = patch(q_function_name, **kwargs)
 request.addfinalizer(_patch.stop)
 return _patch.start()

def function_mock ( request , q_function_name , ** kwargs ) : _patch = patch ( q_function_name , ** kwargs ) request . addfinalizer ( _patch . stop ) return _patch . start ( )
return a mock patching the function with qualified name *q_function_name* .