Page MenuHomePhabricator

test_pages_with_property_generator: NotImplementedError: "disambiguation" is not a valid page property
Closed, ResolvedPublic

Description

https://travis-ci.org/wikimedia/pywikibot-core/jobs/210180324#L3903

=================================== FAILURES ===================================

___________ TestFactoryGenerator.test_pages_with_property_generator ____________

self = <tests.pagegenerators_tests.TestFactoryGenerator testMethod=test_pages_with_property_generator>

    def test_pages_with_property_generator(self):

        """Test the pages_with_property_generator method."""

        mysite = self.get_site()

        for item in ('defaultsort', 'disambiguation', 'displaytitle',

                     'hiddencat', 'invalid_property'):

            if item in mysite.get_property_names():

                gf = pagegenerators.GeneratorFactory()

>               gf.handleArg('-property:{0}'.format(item))

tests/pagegenerators_tests.py:1031: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

pywikibot/pagegenerators.py:681: in handleArg

    gen = page_with_property_generator(value, site=self.site)

pywikibot/pagegenerators.py:2202: in page_with_property_generator

    return site.pages_with_property(name, total=total)

pywikibot/site.py:1357: in callee

    return fn(self, *args, **kwargs)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = APISite("fa", "wiktionary"), propname = 'disambiguation', total = None

    @need_version('1.21')

    def pages_with_property(self, propname, total=None):

        """Yield Page objects from Special:PagesWithProp.

    

            @param propname: must be a valid property.

            @type propname: str

            @param total: number of pages to return

            @type total: int or None

            @return: return a generator of Page objects

            @rtype: iterator

            """

        if propname not in self.get_property_names():

            raise NotImplementedError(

>               '"{0}" is not a valid page property'.format(propname))

E           NotImplementedError: "disambiguation" is not a valid page property

I cannot reproduce this issue on my PC. The strange thing for me is the APISite("fa", "wiktionary"), I don't know where it is coming from.

This test has been added 4 commits ago. In all 4 builds, 6 jobs have failed on this test, 14 have passed it successfully, and one (job number 10) does not execute it.

Event Timeline

The only place in our source code that mentions 'fa' language and 'wiktionary' family is within test_without_repo.

I'm almost certain that this is the cause of this weird error. Calling interwikidata.main overwrites config data.

Change 342325 had a related patch set uploaded (by Dalba):
[pywikibot/core] interwikidata_tests.py: Do not change config while performing tests

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

Change 342325 merged by jenkins-bot:
[pywikibot/core] interwikidata_tests.py: Do not change config while performing tests

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

This comment was removed by Dalba.