

def test_content_flatten_comments(reddit):
    url = 'https://www.reddit.com/r/AskReddit/comments/cmwov'
    submission = reddit.get_submission(url, comment_sort='top')
    more_comment = submission.comments[(- 1)]
    assert isinstance(more_comment, praw.objects.MoreComments)
    comments = more_comment.comments()
    top_level_comments = []
    for comment in comments[:(- 1)]:
        if (comment.parent_id == more_comment.parent_id):
            top_level_comments.append(comment.id)
        else:
            assert comment.parent_id.endswith(top_level_comments[(- 1)])
    top_level_comments.append(comments[(- 1)].id)
    assert isinstance(comments[(- 1)], praw.objects.MoreComments)
    assert (comments[(- 1)].parent_id == more_comment.parent_id)
    flattened = Content.flatten_comments(comments, root_level=2)
    assert (len(flattened) == len(comments))
    for (i, comment) in enumerate(flattened):
        assert (comment.id == comments[i].id)
        if (comment.id in top_level_comments):
            assert (i.nested_level == 2)
        else:
            assert (comment.nested_level > 2)

dataset/ETHPy150Open michael-lazar/rtv/tests/test_content.py test_content_flatten_comments/VarMisuse@240/321 `comment`->`i`