return if the batch is empty
diff --git a/googleapiclient/http.py b/googleapiclient/http.py
index f272ba8..fdce194 100644
--- a/googleapiclient/http.py
+++ b/googleapiclient/http.py
@@ -1288,6 +1288,9 @@
httplib2.HttpLib2Error if a transport error has occured.
googleapiclient.errors.BatchError if the response is the wrong format.
"""
+ # If we have no requests return
+ if len(self._order) == 0:
+ return None
# If http is not supplied use the first valid one given in the requests.
if http is None:
diff --git a/tests/test_http.py b/tests/test_http.py
index c12c7b1..6d296b6 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -766,6 +766,11 @@
self.request1.resumable = upload
self.assertRaises(BatchError, batch.add, self.request1, request_id='1')
+ def test_execute_empty_batch_no_http(self):
+ batch = BatchHttpRequest()
+ ret = batch.execute()
+ self.assertEqual(None, ret)
+
def test_execute(self):
batch = BatchHttpRequest()
callbacks = Callbacks()