def class_mock(request, q_class_name, autospec=True, **kwargs):
 _patch = patch(q_class_name, autospec=autospec, **kwargs)
 request.addfinalizer(_patch.stop)
 return _patch.start()

def class_mock ( request , q_class_name , autospec = True , ** kwargs ) : _patch = patch ( q_class_name , autospec = autospec , ** kwargs ) request . addfinalizer ( _patch . stop ) return _patch . start ( )
return a mock patching the class with qualified name *q_class_name* .