jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/631196 )
Change subject: [cleanup] Cleanup pagegenerators.py and tests
......................................................................
[cleanup] Cleanup pagegenerators.py and tests
Cleanup warnings from IDE, fix docstrings, replace deprecated functions.
Change-Id: I81171d1d1a8f509f2de94acab8ef8412d6be097d
---
M pywikibot/pagegenerators.py
M tests/pagegenerators_tests.py
2 files changed, 11 insertions(+), 10 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 6adcbb0..b301109 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -48,6 +48,7 @@
from pywikibot import date, config, i18n, xmlreader
from pywikibot.bot import ShowingListOption
from pywikibot.comms import http
+from pywikibot.data import api
from pywikibot.exceptions import ServerError, UnknownExtension
from pywikibot.proofreadpage import ProofreadPage
@@ -502,7 +503,7 @@
for i in range(len(self.gens)):
if self.namespaces:
- if (isinstance(self.gens[i], pywikibot.data.api.QueryGenerator)
+ if (isinstance(self.gens[i], api.QueryGenerator)
and self.gens[i].support_namespace()):
self.gens[i].set_namespace(self.namespaces)
# QueryGenerator does not support namespace param.
@@ -1286,7 +1287,7 @@
@deprecated_args(number='total', step=None, namespace='namespaces',
repeat=None, get_redirect=None)
-def NewpagesPageGenerator(site=None, namespaces=[0], total=None):
+def NewpagesPageGenerator(site=None, namespaces=(0, ), total=None):
"""
Iterate Page objects for all new titles in a single namespace.
@@ -1669,10 +1670,10 @@
on_repo = False
if on_repo:
if page.namespace() == page.site.property_namespace:
- cls = pywikibot.PropertyPage
+ page_cls = pywikibot.PropertyPage
else:
- cls = pywikibot.ItemPage
- page = cls(page.site, page.title(with_ns=False))
+ page_cls = pywikibot.ItemPage
+ page = page_cls(page.site, page.title(with_ns=False))
else:
try:
page = pywikibot.ItemPage.fromPage(page)
@@ -1957,6 +1958,7 @@
@param show_filtered: Output a message for each page not yielded
@type show_filtered: bool
"""
+ ts = None
if timestamp:
if isinstance(timestamp, str):
ts = pywikibot.Timestamp.fromtimestampformat(timestamp)
@@ -2169,8 +2171,8 @@
"""
A wrapper generator used to exclude if page has a wikibase item or not.
- @param gen: Generator to wrap.
- @type gen: generator
+ @param generator: Generator to wrap.
+ @type generator: generator
@param has_item: Exclude pages without an item if True, or only
include pages without an item if False
@type has_item: bool
@@ -2660,7 +2662,7 @@
@param start: skip entries below that value
@type start: str or None
@param namespaces: namespace filter
- @type identifiers: iterable of basestring or Namespace key,
+ @type namespaces: iterable of str or Namespace key,
or a single instance of those types
@param site: current site for the generator
@type site: pywikibot.Site or None
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index aef081b..3f16fe1 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -492,7 +492,6 @@
"""Setup class for tests."""
super(TestDayPageGenerator, cls).setUpClass()
cls.site = cls.get_site()
- cls.fd = date.FormatDate(cls.site)
def _run_test(self, start_month=1, end_month=12, year=2000):
"""Test method for DayPageGenerator."""
@@ -516,7 +515,7 @@
expected = []
for month in range(start_month, end_month + 1):
for day in range(1, calendar.monthrange(year, month)[1] + 1):
- expected.append(self.fd(month, day))
+ expected.append(date.format_date(month, day, self.site))
self.assertPageTitlesEqual(gen2, expected)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/631196
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I81171d1d1a8f509f2de94acab8ef8412d6be097d
Gerrit-Change-Number: 631196
Gerrit-PatchSet: 3
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/630808 )
Change subject: [tests] Add a intersect generator test which is known as failing
......................................................................
[tests] Add a intersect generator test which is known as failing
Bug: T263947
Change-Id: I95c0810c8839fdbf7d9c96e880105b21f54a814a
---
M tests/thread_tests.py
1 file changed, 5 insertions(+), 0 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/thread_tests.py b/tests/thread_tests.py
index 81d5ff7..615395b 100644
--- a/tests/thread_tests.py
+++ b/tests/thread_tests.py
@@ -68,6 +68,11 @@
"""Test basic interset with duplicates."""
self.assertEqualItertools(['aabc', 'dddb', 'baa'])
+ @unittest.expectedFailure
+ def test_intersect_with_dups_failing(self):
+ """Failing basic intersect test with duplicates."""
+ self.assertEqualItertools(['abb', 'bb'])
+
if __name__ == '__main__': # pragma: no cover
with suppress(SystemExit):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/630808
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I95c0810c8839fdbf7d9c96e880105b21f54a814a
Gerrit-Change-Number: 630808
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged