Skip to content

Commit 875c1a8

Browse files
committed
- Make sure that sending an empty list to batch() doesn't error out but rather returns an empty list.
- Tests to validate new functionality.
1 parent cd5351b commit 875c1a8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

shotgun_api3/shotgun.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,11 @@ def batch(self, requests):
708708
raise ShotgunError("batch() expects a list. Instead was sent "\
709709
"a %s" % type(requests))
710710

711+
# If we have no requests, just return an empty list immediately.
712+
# Nothing to process means nothing to get results of.
713+
if len(requests) == 0:
714+
return []
715+
711716
calls = []
712717

713718
def _required_keys(message, required_keys, data):

tests/test_api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ def test_batch(self):
6666
result = self.sg.batch(requests)[0]
6767
self.assertEqual(True, result)
6868

69+
def test_empty_batch(self):
70+
"""Empty list sent to .batch()"""
71+
result = self.sg.batch([])
72+
self.assertEqual([], result)
73+
6974
def test_create_update_delete(self):
7075
"""Called create, update, delete, revive"""
7176
data = {

0 commit comments

Comments
 (0)