jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] site_detect_tests: Inform about duplicates
......................................................................
[FEAT] site_detect_tests: Inform about duplicates
Several URLs have been added to the tests multiple times. And assuming each
test yields the same result running it multiple times won't help. This is
purposefully not cleared after each tests as the same URL may also be in
different tests.
Change-Id: Ifedd148a5662b416fe72db445f719860bd6a95c0
---
M tests/site_detect_tests.py
1 file changed, 18 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_detect_tests.py b/tests/site_detect_tests.py
index bcad8cb..4580f41 100644
--- a/tests/site_detect_tests.py
+++ b/tests/site_detect_tests.py
@@ -25,6 +25,11 @@
"""Test Case for MediaWiki detection and site object
creation."""
+ # This list is intentionally shared between all classes
+ _urls_tested = set()
+ # Whether it allows multiple tests of the same URL
+ allow_multiple = False
+
def setUp(self):
"""Set up test."""
self.skips = {}
@@ -32,6 +37,8 @@
self.errors = {}
self.passes = {}
self.all = []
+ # reset after end of test
+ self._previous_multiple = self.allow_multiple
super(TestWikiSiteDetection, self).setUp()
def tearDown(self):
@@ -51,6 +58,7 @@
assert 0 <= pos < len(PREFIXES)
return typ, url, res
+ self.allow_multiple = self._previous_multiple
super(TestWikiSiteDetection, self).tearDown()
print('Out of %d sites, %d tests passed, %d tests failed, '
'%d tests skiped and %d tests raised an error'
@@ -70,6 +78,14 @@
def _wiki_detection(self, url, result):
"""Perform one load test."""
self.all += [url]
+ if url in self._urls_tested:
+ msg = 'Testing URL "{0}" multiple times!'.format(url)
+ if self.allow_multiple:
+ print(msg)
+ else:
+ self.errors[url] = msg
+ return
+ self._urls_tested.add(url)
try:
site = MWSite(url)
except (ServerError, Timeout) as e:
@@ -118,6 +134,8 @@
code = 'meta'
net = True
+ allow_multiple = True
+
def test_IWM(self):
"""Test the load_site method for MW sites on the IWM
list."""
data = self.get_site().siteinfo['interwikimap']
--
To view, visit
https://gerrit.wikimedia.org/r/238701
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifedd148a5662b416fe72db445f719860bd6a95c0
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>