当前位置: 首页>>代码示例>>Python>>正文


Python SubredditContent.iterate方法代码示例

本文整理汇总了Python中rtv.content.SubredditContent.iterate方法的典型用法代码示例。如果您正苦于以下问题:Python SubredditContent.iterate方法的具体用法?Python SubredditContent.iterate怎么用?Python SubredditContent.iterate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rtv.content.SubredditContent的用法示例。


在下文中一共展示了SubredditContent.iterate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_content_subreddit_load_more

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import iterate [as 别名]
def test_content_subreddit_load_more(reddit, terminal):

    submissions = reddit.get_front_page(limit=None)
    content = SubredditContent('front', submissions, terminal.loader)

    assert content.get(50)['type'] == 'Submission'
    assert len(content._submission_data) == 51

    for data in 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)
开发者ID:rpesche,项目名称:rtv,代码行数:16,代码来源:test_content.py

示例2: test_content_subreddit_load_more

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import iterate [as 别名]
def test_content_subreddit_load_more(reddit, terminal):

    submissions = reddit.get_front_page(limit=None)
    content = SubredditContent('front', submissions, terminal.loader)

    assert content.get(50)['type'] == 'Submission'
    assert content.range == (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))
开发者ID:prabhath6,项目名称:rtv,代码行数:20,代码来源:test_content.py

示例3: test_content_subreddit

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import iterate [as 别名]
def test_content_subreddit(reddit, terminal):

    submissions = reddit.get_front_page(limit=5)
    content = SubredditContent('front', submissions, terminal.loader)

    # Submissions are loaded on demand, excluding for the first one
    assert len(content._submission_data) == 1
    assert content.get(0)['type'] == 'Submission'

    for data in content.iterate(0, 1):
        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)

    # Out of bounds
    with pytest.raises(IndexError):
        content.get(-1)
    with pytest.raises(IndexError):
        content.get(5)
开发者ID:rpesche,项目名称:rtv,代码行数:23,代码来源:test_content.py


注:本文中的rtv.content.SubredditContent.iterate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。