jenkins-bot has submitted this change and it was merged.
Change subject: RC tests: Use en.wp instead of test.wd or test.wp ......................................................................
RC tests: Use en.wp instead of test.wd or test.wp
If a travis build has not been set up with a username, pywikibot will default to using test.wikipedia as the test site.
Builds against Wikimedia 'test' sites can be effectively halted waiting for three edits to appear on the live RC feed.
Also change RepeatingGenerator RC tests to use default site, unless it is a test site.
Change-Id: I94f569d9f40a2ed43d45f4ab11c8cb9e25bbd4bd --- M tests/aspects.py M tests/pagegenerators_tests.py 2 files changed, 36 insertions(+), 21 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/aspects.py b/tests/aspects.py index 1fb1728..78cd606 100644 --- a/tests/aspects.py +++ b/tests/aspects.py @@ -930,6 +930,23 @@ family = config.family code = config.mylang
+ @classmethod + def override_default_site(cls, site): + print('%s using %s instead of %s:%s.' + % (cls.__name__, site, cls.family, cls.code)) + cls.site = site + cls.family = site.family.name + cls.code = site.code + + cls.sites = { + cls.site: { + 'family': cls.family, + 'code': cls.code, + 'site': cls.site, + 'hostname': cls.site.hostname(), + } + } +
class AlteredDefaultSiteTestCase(TestCase):
@@ -995,19 +1012,7 @@ site = cls.get_site()
if not isinstance(site.family, WikimediaFamily): - print('%s using English Wikipedia instead of non-WMF config.family %s.' - % (cls.__name__, cls.family)) - cls.family = 'wikipedia' - cls.code = 'en' - cls.site = pywikibot.Site('en', 'wikipedia') - cls.sites = { - cls.site: { - 'family': 'wikipedia', - 'code': 'en', - 'site': cls.site, - 'hostname': cls.site.hostname(), - } - } + cls.override_default_site(pywikibot.Site('en', 'wikipedia'))
class WikibaseTestCase(TestCase): diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py index 7269493..7a160b4 100755 --- a/tests/pagegenerators_tests.py +++ b/tests/pagegenerators_tests.py @@ -232,30 +232,37 @@ self.assertEqual(len(list(gen)), 0)
-class TestRepeatingGenerator(TestCase): +class TestRepeatingGenerator(WikimediaDefaultSiteTestCase):
"""Test RepeatingGenerator."""
- family = 'wikipedia' - code = 'en' + # site.recentchanges() includes external edits from wikidata, + # except on wiktionaries which are not linked to wikidata + # so total=3 should not be too high for most sites. + length = 3 + + @classmethod + def setUpClass(cls): + super(TestRepeatingGenerator, cls).setUpClass() + + if cls.get_site().code == 'test': + cls.override_default_site(pywikibot.Site('en', 'wikipedia'))
def test_RepeatingGenerator(self): - # site.recentchanges() includes external edits (from wikidata), - # so total=4 is not too high items = list( pagegenerators.RepeatingGenerator(self.site.recentchanges, key_func=lambda x: x['revid'], sleep_duration=10, reverse=True, namespaces=[0], - total=4) + total=self.length) ) - self.assertEqual(len(items), 4) + self.assertEqual(len(items), self.length) timestamps = [pywikibot.Timestamp.fromISOformat(item['timestamp']) for item in items] self.assertEqual(sorted(timestamps), timestamps) self.assertTrue(all(item['ns'] == 0 for item in items)) - self.assertEqual(len(set(item['revid'] for item in items)), 4) + self.assertEqual(len(set(item['revid'] for item in items)), self.length)
class TestTextfilePageGenerator(DefaultSiteTestCase): @@ -838,6 +845,9 @@ 'socketIO_client %s not supported by Wikimedia-Stream' % socketIO_client.__version__)
+ if cls.get_site().code == 'test': + cls.override_default_site(pywikibot.Site('en', 'wikipedia')) + def test_RC_pagegenerator_result(self): import logging lgr = logging.getLogger('socketIO_client')