jenkins-bot has submitted this change and it was merged.
Change subject: Compute page length in bytes in test_allpages_pagesize ......................................................................
Compute page length in bytes in test_allpages_pagesize
API:allpages assumes page length is in bytes. site.encoding() is used to convert from unicode to bytes.
Bug: T85663 Change-Id: I2cb49ba31543d7c48c71f25e686e2e7ede1b0122 --- M tests/site_tests.py 1 file changed, 6 insertions(+), 3 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py index eb377c4..eecbb74 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -430,15 +430,18 @@ for page in mysite.allpages(minsize=100, total=5): self.assertIsInstance(page, pywikibot.Page) self.assertTrue(mysite.page_exists(page)) - self.assertGreaterEqual(len(page.text), 100) + self.assertGreaterEqual(len(page.text.encode(mysite.encoding())), + 100) for page in mysite.allpages(maxsize=200, total=5): self.assertIsInstance(page, pywikibot.Page) self.assertTrue(mysite.page_exists(page)) - if len(page.text) > 200 and mysite.data_repository() == mysite: + if (len(page.text.encode(mysite.encoding())) > 200 and + mysite.data_repository() == mysite): print('%s.text is > 200 bytes while raw JSON is <= 200' % page) continue - self.assertLessEqual(len(page.text), 200) + self.assertLessEqual(len(page.text.encode(mysite.encoding())), + 200)
def test_allpages_protection(self): mysite = self.get_site()
pywikibot-commits@lists.wikimedia.org