Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #687 from OliverCardoza/master
Browse files Browse the repository at this point in the history
Fix GetListMembers not paginating
  • Loading branch information
bear authored Dec 19, 2021
2 parents 09217e8 + c016088 commit 773bce9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion testdata/get_list_members_0.json

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions tests/test_api_30.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ def testGetListMembers(self):
resp = self.api.GetListMembers(list_id=93527328)
self.assertTrue(type(resp[0]) is twitter.User)
self.assertEqual(resp[0].id, 4048395140)
self.assertEqual(len(resp), 47)

@responses.activate
def testGetListMembersPaged(self):
Expand All @@ -820,8 +821,10 @@ def testGetListMembersPaged(self):
body=resp_data,
match_querystring=True,
status=200)
resp = self.api.GetListMembersPaged(list_id=93527328, cursor=4611686020936348428)
_, _, resp = self.api.GetListMembersPaged(list_id=93527328,
cursor=4611686020936348428)
self.assertTrue([isinstance(u, twitter.User) for u in resp])
self.assertEqual(len(resp), 20)

with open('testdata/get_list_members_extra_params.json') as f:
resp_data = f.read()
Expand All @@ -837,6 +840,7 @@ def testGetListMembersPaged(self):
include_entities=False,
count=100)
self.assertFalse(resp[0].status)
self.assertEqual(len(resp), 27)

@responses.activate
def testGetListTimeline(self):
Expand Down Expand Up @@ -1017,7 +1021,7 @@ def testGetSubscriptionsSN(self):

resp = self.api.GetSubscriptions(screen_name='inky')
self.assertEqual(len(resp), 20)
self.assertTrue([isinstance(l, twitter.List) for l in resp])
self.assertTrue([isinstance(lst, twitter.List) for lst in resp])

@responses.activate
def testGetMemberships(self):
Expand Down Expand Up @@ -1289,7 +1293,7 @@ def testGetStatuses(self):
rsps.add(GET, DEFAULT_URL, body=resp_data)

with open('testdata/get_statuses.ids.txt') as f:
status_ids = [int(l) for l in f]
status_ids = [int(line) for line in f]

resp = self.api.GetStatuses(status_ids)

Expand All @@ -1312,7 +1316,7 @@ def testGetStatusesMap(self):
rsps.add(GET, DEFAULT_URL, body=resp_data)

with open('testdata/get_statuses.ids.txt') as f:
status_ids = [int(l) for l in f]
status_ids = [int(line) for line in f]

resp = self.api.GetStatuses(status_ids, map=True)

Expand Down
2 changes: 1 addition & 1 deletion twitter/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4294,7 +4294,7 @@ def GetListMembers(self,
include_entities=include_entities)
result += users

if next_cursor == 0 or next_cursor == previous_cursor:
if next_cursor == 0:
break
else:
cursor = next_cursor
Expand Down

0 comments on commit 773bce9

Please sign in to comment.