Skip to content

Commit

Permalink
Merge pull request #1103 from Pyprohly/replies
Browse files Browse the repository at this point in the history
Initialise `.replies` to an empty list
  • Loading branch information
bboe committed Jul 11, 2019
2 parents 6255a1a + 15299ed commit 5aa2865
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions praw/models/reddit/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ def __init__(
raise TypeError(
"Exactly one of `id`, `url`, or `_data` must be provided."
)
self._replies = self._submission = None
self._replies = []
self._submission = None
super(Comment, self).__init__(reddit, _data=_data)
if id:
self.id = id # pylint: disable=invalid-name
self.id = id
elif url:
self.id = self.id_from_url(url)
else:
Expand Down
4 changes: 2 additions & 2 deletions praw/models/reddit/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def __init__(
raise TypeError("Either `id` or `_data` must be provided.")
super(LiveThread, self).__init__(reddit, _data=_data)
if id:
self.id = id # pylint: disable=invalid-name
self.id = id

def _fetch_info(self):
return ("liveabout", {"id": self.id}, None)
Expand Down Expand Up @@ -617,7 +617,7 @@ def __init__(self, reddit, thread_id=None, update_id=None, _data=None):
elif thread_id and update_id:
super(LiveUpdate, self).__init__(reddit, _data=None)
self._thread = LiveThread(self._reddit, thread_id)
self.id = update_id # pylint: disable=invalid-name
self.id = update_id
else:
raise TypeError(
"Either `thread_id` and `update_id`, or "
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(
raise TypeError("Either `id` or `_data` must be provided.")

if id:
self.id = id # pylint: disable=invalid-name
self.id = id

self._info_params = {"markRead": True} if mark_read else None

Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def __init__(
self.comment_sort = "best"

if id is not None:
self.id = id # pylint: disable=invalid-name
self.id = id
elif url is not None:
self.id = self.id_from_url(url)

Expand Down
6 changes: 4 additions & 2 deletions tests/integration/models/reddit/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ def test_parent__submission(self):
assert parent.fullname == comment.parent_id

def test_refresh(self):
comment = Comment(self.reddit, "d81vwef")
with self.recorder.use_cassette("TestComment.test_refresh"):
comment = Comment(self.reddit, "d81vwef").refresh()
assert len(comment.replies) > 0
assert len(comment.replies) == 0
comment.refresh()
assert len(comment.replies) > 0

def test_refresh__raises_exception(self):
with self.recorder.use_cassette(
Expand Down

0 comments on commit 5aa2865

Please sign in to comment.