jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1335072?usp=email )

Change subject: tests: Reuse links in preload tests
......................................................................

tests: Reuse links in preload tests

Reuse the links fetched to determine the result count when exercising
high and low preload group sizes. This avoids repeating the same live
pagelinks request in both tests.

Bug: T434934
Change-Id: Ic8fcef8e073b75443cef0ce2b6f3e0b8c7e7b51f
---
M tests/site_generators_tests.py
1 file changed, 4 insertions(+), 8 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/tests/site_generators_tests.py b/tests/site_generators_tests.py
index da7f393..190881c 100755
--- a/tests/site_generators_tests.py
+++ b/tests/site_generators_tests.py
@@ -2246,13 +2246,11 @@

         # Determine if there are enough links on the main page,
         # for the test to be useful.
-        link_count = len(list(mysite.pagelinks(mainpage, total=10)))
+        links = list(mysite.pagelinks(mainpage, total=10))
+        link_count = len(links)
         if link_count < 2:
             self.skipTest('insufficient links on main page')

-        # get a fresh generator; we now know how many results it will have,
-        # if it is less than 10.
-        links = mysite.pagelinks(mainpage, total=10)
         count = 0
         for count, page in enumerate(
                 mysite.preloadpages(links, groupsize=50), start=1):
@@ -2271,13 +2269,11 @@

         # Determine if there are enough links on the main page,
         # for the test to be useful.
-        link_count = len(list(mysite.pagelinks(mainpage, total=10)))
+        links = list(mysite.pagelinks(mainpage, total=10))
+        link_count = len(links)
         if link_count < 2:
             self.skipTest('insufficient links on main page')

-        # get a fresh generator; we now know how many results it will have,
-        # if it is less than 10.
-        links = mysite.pagelinks(mainpage, total=10)
         count = 0
         for count, page in enumerate(
                 mysite.preloadpages(links, groupsize=5), start=1):

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1335072?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ic8fcef8e073b75443cef0ce2b6f3e0b8c7e7b51f
Gerrit-Change-Number: 1335072
Gerrit-PatchSet: 1
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to