Page MenuHomePhabricator

TestUnconnectedPageGenerator.test_unconnected_with_repo occasionally fails with AssertionError
Closed, ResolvedPublic

Description

https://travis-ci.org/wikimedia/pywikibot-core/jobs/226186262#L3970

___________ TestUnconnectedPageGenerator.test_unconnected_with_repo ____________

self = <tests.pagegenerators_tests.TestUnconnectedPageGenerator testMethod=test_unconnected_with_repo>

    def test_unconnected_with_repo(self):

        """Test that the ItemPage returned raises NoPage."""

        if not self.site.data_repository():

            raise unittest.SkipTest('Site is not using a Wikibase repository')

        if self.site.hostname() == 'test.wikipedia.org':

            raise unittest.SkipTest('test.wikipedia is misconfigured; T85358')

        cnt = 0

        start_time = datetime.datetime.now() - datetime.timedelta(minutes=5)

        # Pages which have been connected recently may still be reported as

        # unconnected. So try on an version that is a few minutes older if the

        # tested site appears as a sitelink.

        for page in self.site.unconnected_pages(total=5):

            try:

                item = pywikibot.ItemPage.fromPage(page)

            except pywikibot.NoPage:

                pass

            else:

                revisions = list(item.revisions(total=1, starttime=start_time,

                                                content=True))

                if revisions:

                    sitelinks = json.loads(revisions[0].text)['sitelinks']

                    self.assertNotIn(

                        self.site.dbName(), sitelinks,

                        'Page "{0}" is connected to a Wikibase '

>                       'repository'.format(page.title()))

E                   AssertionError: Page "Zoltán Remák" is connected to a Wikibase repository

I think I fixed a very similar test in T163619: TestSiteGenerators.test_unconnected occasionally fails (50f01ee9fd74).

Event Timeline

It seems that the purpose of the one in pagegenerators_tests.py has been to test pagegenerators.UnconnectedPageGenerator and the other site.unconnected_pages, but in 201a2e4db17cfba8476b5065a05312619836dd20 both have been changed to site.unconnected_pages.

Change 350536 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] pagegenerators_tests.py: Fix test_unconnected_with_repo

https://gerrit.wikimedia.org/r/350536

Change 350536 merged by jenkins-bot:
[pywikibot/core@master] pagegenerators_tests.py: Fix test_unconnected_with_repo

https://gerrit.wikimedia.org/r/350536