Fix bug where submission indicies were duplicated when paging. #209
This commit is contained in:
@@ -439,9 +439,9 @@ class SubredditContent(Content):
|
||||
raise IndexError
|
||||
else:
|
||||
data = self.strip_praw_submission(submission)
|
||||
data['index'] = index
|
||||
data['index'] = len(self._submission_data) + 1
|
||||
# Add the post number to the beginning of the title
|
||||
data['title'] = '{0}. {1}'.format(index+1, data['title'])
|
||||
data['title'] = '{0}. {1}'.format(data['index'], data['title'])
|
||||
self._submission_data.append(data)
|
||||
|
||||
# Modifies the original dict, faster than copying
|
||||
|
||||
@@ -216,13 +216,16 @@ def test_content_subreddit_load_more(reddit, terminal):
|
||||
assert content.get(50)['type'] == 'Submission'
|
||||
assert len(content._submission_data) == 51
|
||||
|
||||
for data in islice(content.iterate(0, 1), 0, 50):
|
||||
for i, data in enumerate(islice(content.iterate(0, 1), 0, 50)):
|
||||
assert all(k in data for k in ('object', 'n_rows', 'offset', 'type',
|
||||
'index', 'title', 'split_title'))
|
||||
# All text should be converted to unicode by this point
|
||||
for val in data.values():
|
||||
assert not isinstance(val, six.binary_type)
|
||||
|
||||
# Index be appended to each title, starting at "1." and incrementing
|
||||
assert data['index'] == i + 1
|
||||
assert data['title'].startswith(six.text_type(i + 1))
|
||||
|
||||
def test_content_subreddit_from_name(reddit, terminal):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user