本文整理匯總了Python中pywikibot.proofreadpage.IndexPage.get_number方法的典型用法代碼示例。如果您正苦於以下問題:Python IndexPage.get_number方法的具體用法?Python IndexPage.get_number怎麽用?Python IndexPage.get_number使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pywikibot.proofreadpage.IndexPage
的用法示例。
在下文中一共展示了IndexPage.get_number方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_page_and_number
# 需要導入模塊: from pywikibot.proofreadpage import IndexPage [as 別名]
# 或者: from pywikibot.proofreadpage.IndexPage import get_number [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)