Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df43dbf

Browse files
Merge pull request googleapis#119 from zeapo/master
Return if the batch is empty in BatchHttpRequest.execute.
2 parents 1339a55 + 1b5350d commit df43dbf

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

googleapiclient/http.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,9 @@ def execute(self, http=None):
12881288
httplib2.HttpLib2Error if a transport error has occured.
12891289
googleapiclient.errors.BatchError if the response is the wrong format.
12901290
"""
1291+
# If we have no requests return
1292+
if len(self._order) == 0:
1293+
return None
12911294

12921295
# If http is not supplied use the first valid one given in the requests.
12931296
if http is None:

tests/test_http.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,11 @@ def test_add_fail_for_resumable(self):
766766
self.request1.resumable = upload
767767
self.assertRaises(BatchError, batch.add, self.request1, request_id='1')
768768

769+
def test_execute_empty_batch_no_http(self):
770+
batch = BatchHttpRequest()
771+
ret = batch.execute()
772+
self.assertEqual(None, ret)
773+
769774
def test_execute(self):
770775
batch = BatchHttpRequest()
771776
callbacks = Callbacks()

0 commit comments

Comments
 (0)