jenkins-bot has submitted this change and it was merged.
Change subject: intersect_generators cache simplification
......................................................................
intersect_generators cache simplification
The cache values for intersect_generators do not
need to contain a tuple including the item, as all
members of the set will be the same item.
Change-Id: I6de064422d35625b50d4ff7b630041368d51de81
---
M pywikibot/tools/__init__.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index b7de462..3e9bb9d 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -555,9 +555,9 @@
# TODO: evaluate if True and timeout is necessary.
item = t.queue.get(True, 0.1)
- # Cache entry is a set of tuples (item, thread).
+ # Cache entry is a set of thread.
# Duplicates from same thread are not counted twice.
- cache[item].add((item, t))
+ cache[item].add(t)
if len(cache[item]) == n_gen:
yield item
# Remove item from cache.
--
To view, visit https://gerrit.wikimedia.org/r/202949
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6de064422d35625b50d4ff7b630041368d51de81
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Expand testReprUnicode to validate the result
......................................................................
Expand testReprUnicode to validate the result
The repr(Page) test was very simple, only checking the type returned.
This expanded set of tests passes if applied before 1e54a7d6
so that any fix to Page.__repr__ after 1e54a7d6 can behave the same
as before unicode_literals.
Change-Id: I5e0ce794d38c047fef2c72c50664830175fbc64a
---
M tests/page_tests.py
1 file changed, 39 insertions(+), 11 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/page_tests.py b/tests/page_tests.py
index d170cab..94a1c2a 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -14,7 +14,7 @@
import pywikibot.page
from tests.aspects import unittest, TestCase, DefaultSiteTestCase
-from tests.utils import allowed_failure
+from tests.utils import allowed_failure, expected_failure_if
if sys.version_info[0] > 2:
basestring = (str, )
@@ -492,16 +492,6 @@
mainpage_unpickled = pickle.loads(mainpage_str)
self.assertEqual(mainpage, mainpage_unpickled)
- def testRepr(self):
- mainpage = self.get_mainpage()
- s = repr(mainpage)
- self.assertIsInstance(s, str)
-
- def testReprUnicode(self):
- page = pywikibot.Page(self.get_site(), u'Ō')
- s = repr(page)
- self.assertIsInstance(s, str)
-
def test_redirect(self):
"""Test that the redirect option is set correctly."""
site = self.get_site()
@@ -522,6 +512,44 @@
self.assertTrue(page_copy.isRedirectPage())
+class TestPageRepr(DefaultSiteTestCase):
+
+ """Test Page representation."""
+
+ cached = True
+
+ def test_mainpage_type(self):
+ u"""Test the return type of repr(Page(<main page>)) is str."""
+ mainpage = self.get_mainpage()
+ self.assertIsInstance(repr(mainpage), str)
+
+ def test_unicode_type(self):
+ """Test the return type of repr(Page(u'<non-ascii>')) is str."""
+ page = pywikibot.Page(self.get_site(), u'Ō')
+ self.assertIsInstance(repr(page), str)
+
+ @expected_failure_if(sys.version_info[0] > 2)
+ def test_unicode_value(self):
+ """Test repr(Page(u'<non-ascii>')) is represented simply as utf8."""
+ page = pywikibot.Page(self.get_site(), u'Ō')
+ self.assertEqual(repr(page), b'Page(\xc5\x8c)')
+
+ @unittest.skipIf(sys.version_info[0] > 2, 'Python 2 specific test')
+ def test_unicode_percent_r_failure(self):
+ """Test u'{x!r}'.format(Page(u'<non-ascii>')) raises exception on Python 2."""
+ # This raises an exception on Python 2, but passes on Python 3
+ page = pywikibot.Page(self.get_site(), u'Ō')
+ self.assertRaisesRegex(UnicodeDecodeError, '', unicode.format, u'{0!r}', page)
+
+ @unittest.skipIf(sys.version_info[0] < 3, 'Python 3+ specific test')
+ def test_unicode_value_py3(self):
+ """Test to capture actual Python 3 result pre unicode_literals."""
+ page = pywikibot.Page(self.get_site(), u'Ō')
+ self.assertEqual(repr(page), "Page(b'\\xc5\\x8c')")
+ self.assertEqual(u'%r' % page, "Page(b'\\xc5\\x8c')")
+ self.assertEqual(u'{0!r}'.format(page), "Page(b'\\xc5\\x8c')")
+
+
class TestPageBotMayEdit(TestCase):
"""Test Page.botMayEdit() method."""
--
To view, visit https://gerrit.wikimedia.org/r/203515
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5e0ce794d38c047fef2c72c50664830175fbc64a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: intersect: Dont use %r to log Page generator
......................................................................
intersect: Dont use %r to log Page generator
If one of the generators is a collection, %r will
list all of the pages, which could be very large,
and also very ugly if the Page titles are not ascii
as %r should force the titles to be ascii, causing
some form of encoding fallback like backslashes.
Change-Id: Ifb8f654861fb7d96994bd4611c3613ad036ce81f
---
M pywikibot/tools/__init__.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index b7de462..7a4bd59 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -500,7 +500,8 @@
time.sleep(2)
super(ThreadList, self).append(thd)
thd.start()
- debug("thread started: %r" % thd, self._logger)
+ debug("thread %d ('%s') started" % (len(self), type(thd)),
+ self._logger)
def stop_all(self):
"""Stop all threads the pool."""
--
To view, visit https://gerrit.wikimedia.org/r/203482
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifb8f654861fb7d96994bd4611c3613ad036ce81f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2115
Status: Errored
Duration: 45 minutes and 59 seconds
Commit: 4426e88 (master)
Author: Fabian Neundorf
Message: [FIX] Win32 UI: Explicitly use bytes in Python 2
When searching for a unicode via 'in' in bytes it'll try decoding the
bytes which might fail if it doesn't contain ASCII characters.
Bug: T95671
Change-Id: I5ecf0539b4b056ba14a59fcce4cce595815c2ff7
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/e31b1d4497db...4426e881…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/58022040
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications