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


Python IndexPage.get_page_number_from_label方法代码示例

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


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

示例1: test_get_page_number

# 需要导入模块: from pywikibot.proofreadpage import IndexPage [as 别名]
# 或者: from pywikibot.proofreadpage.IndexPage import get_page_number_from_label [as 别名]
    def test_get_page_number(self, key):
        """Test IndexPage page get_page_number functions."""
        data = self.sites[key]
        index_page = IndexPage(self.site, self.sites[key]["index"])

        # Test get_page_numbers_from_label.
        for label, num_set in data["get_number"]:
            # Get set of numbers from label with label as int or str.
            self.assertEqual(index_page.get_page_number_from_label(label), num_set)
            self.assertEqual(index_page.get_page_number_from_label(str(label)), num_set)

        # Error if label does not exists.
        label, num_set = "dummy label", []
        self.assertRaises(KeyError, index_page.get_page_number_from_label, "dummy label")

        # Test get_page_from_label.
        for label, page_set in data["get_page"]:
            # Get set of pages from label with label as int or str.
            self.assertEqual(index_page.get_page_from_label(label), page_set)
            self.assertEqual(index_page.get_page_from_label(str(label)), page_set)

        # Error if label does not exists.
        self.assertRaises(KeyError, index_page.get_page_from_label, "dummy label")

        # Test consistency of page <-> numbers mapping on last page_set and
        # num_set used.
        for p in page_set:
            n = index_page._numbers_from_page[p]
            self.assertEqual(index_page._page_from_numbers[n], p)
        for n in num_set:
            n = index_page._page_from_numbers[p]
            self.assertEqual(index_page._numbers_from_page[p], n)
开发者ID:Annie201,项目名称:pywikibot-core,代码行数:34,代码来源:proofreadpage_tests.py

示例2: test_get_page_and_number

# 需要导入模块: from pywikibot.proofreadpage import IndexPage [as 别名]
# 或者: from pywikibot.proofreadpage.IndexPage import get_page_number_from_label [as 别名]
    def test_get_page_and_number(self, key):
        """Test IndexPage page get_page_number functions."""
        data = self.sites[key]
        index_page = IndexPage(self.site, self.sites[key]['index'])

        # Test get_page_numbers_from_label.
        for label, num_set in data['get_number']:
            # Get set of numbers from label with label as int or str.
            self.assertEqual(index_page.get_page_number_from_label(label),
                             num_set)
            self.assertEqual(index_page.get_page_number_from_label(str(label)),
                             num_set)

        # Error if label does not exists.
        label, num_set = 'dummy label', []
        self.assertRaises(KeyError, index_page.get_page_number_from_label,
                          'dummy label')

        # Test get_page_from_label.
        for label, page_set in data['get_page']:
            # Get set of pages from label with label as int or str.
            self.assertEqual(index_page.get_page_from_label(label),
                             page_set)
            self.assertEqual(index_page.get_page_from_label(str(label)),
                             page_set)

        # Error if label does not exists.
        self.assertRaises(KeyError, index_page.get_page_from_label, 'dummy label')

        # Test get_page.
        for n in num_set:
            p = index_page.get_page(n)
            self.assertEqual(index_page.get_number(p), n)

        # Test get_number.
        for p in page_set:
            n = index_page.get_number(p)
            self.assertEqual(index_page.get_page(n), p)
开发者ID:PersianWikipedia,项目名称:pywikibot-core,代码行数:40,代码来源:proofreadpage_tests.py


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