@pytest.fixture
def api_client_inject_project_id(cloud_config):
 import googleapiclient.http
 class ProjectIdInjectingHttpRequest(googleapiclient.http.HttpRequest, ):
  def __init__(self, http, postproc, uri, *args, **kwargs):
   uri = uri.replace('YOUR_PROJECT_ID', cloud_config.project)
   super(ProjectIdInjectingHttpRequest, self).__init__(http, postproc, uri, *args, **kwargs)
 with mock.patch('googleapiclient.http.HttpRequest', new=ProjectIdInjectingHttpRequest):
  (yield)

@ pytest . fixture def api_client_inject_project_id ( cloud_config ) : import googleapiclient . http class ProjectIdInjectingHttpRequest ( googleapiclient . http . HttpRequest , ) : def __init__ ( self , http , postproc , uri , * args , ** kwargs ) : uri = uri . replace ( 'YOUR_PROJECT_ID' , cloud_config . project ) super ( ProjectIdInjectingHttpRequest , self ) . __init__ ( http , postproc , uri , * args , ** kwargs ) with mock . patch ( 'googleapiclient.http.HttpRequest' , new = ProjectIdInjectingHttpRequest ) : ( yield )
patches all googleapiclient requests to replace your_project_id with the project id from cloud_config .