當前位置: 首頁>>代碼示例>>Python>>正文


Python IndexPage.get_page方法代碼示例

本文整理匯總了Python中pywikibot.proofreadpage.IndexPage.get_page方法的典型用法代碼示例。如果您正苦於以下問題:Python IndexPage.get_page方法的具體用法?Python IndexPage.get_page怎麽用?Python IndexPage.get_page使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pywikibot.proofreadpage.IndexPage的用法示例。


在下文中一共展示了IndexPage.get_page方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_page_and_number

# 需要導入模塊: from pywikibot.proofreadpage import IndexPage [as 別名]
# 或者: from pywikibot.proofreadpage.IndexPage import get_page [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方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。