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


Python IndexPage.get_label_from_page方法代码示例

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


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

示例1: test_get_labels

# 需要导入模块: from pywikibot.proofreadpage import IndexPage [as 别名]
# 或者: from pywikibot.proofreadpage.IndexPage import get_label_from_page [as 别名]
    def test_get_labels(self, key):
        """Test IndexPage page get_label_from_* functions."""
        data = self.sites[key]
        num, title_num, label = data['get_label']

        index_page = IndexPage(self.site, self.sites[key]['index'])
        page_title = self.sites[key]['page'].format(title_num)
        proofread_page = ProofreadPage(self.site, page_title)

        # Get label from number.
        self.assertEqual(index_page.get_label_from_page_number(num), label)
        # Error if number does not exists.
        self.assertRaises(KeyError, index_page.get_label_from_page_number, -1)

        # Get label from page.
        self.assertEqual(index_page.get_label_from_page(proofread_page), label)
        # Error if page does not exists.
        self.assertRaises(KeyError, index_page.get_label_from_page, None)
开发者ID:PersianWikipedia,项目名称:pywikibot-core,代码行数:20,代码来源:proofreadpage_tests.py

示例2: test_page_number_mapping

# 需要导入模块: from pywikibot.proofreadpage import IndexPage [as 别名]
# 或者: from pywikibot.proofreadpage.IndexPage import get_label_from_page [as 别名]
    def test_page_number_mapping(self, key):
        """Test consistency of page <-> mapping."""
        data = self.sites[key]
        num, title_num, label = data["get_label"]

        index_page = IndexPage(self.site, self.sites[key]["index"])
        page_title = self.sites[key]["page"].format(title_num)
        proofread_page = ProofreadPage(self.site, page_title)

        # Get label from number.
        self.assertEqual(index_page.get_label_from_page_number(num), label)
        # Error if number does not exists.
        self.assertRaises(KeyError, index_page.get_label_from_page_number, -1)

        # Get label from page.
        self.assertEqual(index_page.get_label_from_page(proofread_page), label)
        # Error if page does not exists.
        self.assertRaises(KeyError, index_page.get_label_from_page, None)
开发者ID:Annie201,项目名称:pywikibot-core,代码行数:20,代码来源:proofreadpage_tests.py


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