Page MenuHomePhabricator

Travis fails on generate_family_file_tests.TestGenerateFamilyFiles
Closed, ResolvedPublic

Description

https://travis-ci.org/wikimedia/pywikibot/jobs/640945627#L1238

en:wsbeta py3.5
______________ TestGenerateFamilyFiles.test_attributes_after_run _______________

self = <tests.generate_family_file_tests.TestGenerateFamilyFiles testMethod=test_attributes_after_run>

    def test_attributes_after_run(self):

        """Test FamilyFileGenerator attributes after run()."""

        gen = self.generator_instance

        gen.run()

    

        with self.subTest(test='Test whether default is loaded'):

            self.assertIn(self.site.lang, gen.wikis)

    

        with self.subTest(test='Test element counts'):

            if self.site.lang not in gen.prefixes:

                gen.prefixes += [self.site.lang]

>           self.assertCountEqual(gen.prefixes, gen.wikis)

E           AssertionError: Element counts were not equal:

E           First has 1, Second has 0:  'es'

E           First has 1, Second has 0:  'ja'

E           First has 1, Second has 0:  'sv'

E           First has 1, Second has 0:  'sr'

E           First has 1, Second has 0:  'zh'

E           First has 1, Second has 0:  'eo'

E           First has 1, Second has 0:  'uk'

E           First has 1, Second has 0:  'nl'

E           First has 1, Second has 0:  'ar'

tests/generate_family_file_tests.py:74: AssertionError

------------------------------ Captured log call -------------------------------

logging.py                 109 VERBOSE  https://en.wikisource.beta.wmflabs.org redirected to https://en.wikisource.beta.wmflabs.org/wiki/Main_Page

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://en.wikisource.beta.wmflabs.org/wiki/Main_Page

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://es.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://ja.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://sv.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://sr.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://zh.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://eo.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://uk.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://nl.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://ar.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

https://travis-ci.org/wikimedia/pywikibot/jobs/640945628#L1168

en:musicbrainz py3.5
______________ TestGenerateFamilyFiles.test_attributes_after_run _______________

self = <tests.generate_family_file_tests.TestGenerateFamilyFiles testMethod=test_attributes_after_run>

    def test_attributes_after_run(self):

        """Test FamilyFileGenerator attributes after run()."""

        gen = self.generator_instance

>       gen.run()

tests/generate_family_file_tests.py:66: 

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

generate_family_file.py:63: in run

    self.getapis()

tests/generate_family_file_tests.py:32: in getapis

    self.langs = sample(save, 10)

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

self = <random.Random object at 0x11a3b58>

population = [{'language': 'Аҧсшәа', 'local': '', 'prefix': 'ab', 'url': 'https://acousticbrainz.org/$1'}, {'language': 'Lëtzebuerg...tps://listenbrainz.org/$1'}, {'language': 'en', 'local': '', 'prefix': 'en', 'url': 'https://wiki.musicbrainz.org/$1'}]

k = 10

    def sample(self, population, k):

        """Chooses k unique random elements from a population sequence or set.

    

        Returns a new list containing elements from the population while

        leaving the original population unchanged.  The resulting list is

        in selection order so that all sub-slices will also be valid random

        samples.  This allows raffle winners (the sample) to be partitioned

        into grand prize and second place winners (the subslices).

    

        Members of the population need not be hashable or unique.  If the

        population contains repeats, then each occurrence is a possible

        selection in the sample.

    

        To choose a sample in a range of integers, use range as an argument.

        This is especially fast and space efficient for sampling from a

        large population:   sample(range(10000000), 60)

        """

    

        # Sampling without replacement entails tracking either potential

        # selections (the pool) in a list or previous selections in a set.

    

        # When the number of selections is small compared to the

        # population, then tracking selections is efficient, requiring

        # only a small set and an occasional reselection.  For

        # a larger number of selections, the pool tracking method is

        # preferred since the list takes less space than the

        # set and it doesn't suffer from frequent reselections.

    

        if isinstance(population, _Set):

            population = tuple(population)

        if not isinstance(population, _Sequence):

            raise TypeError("Population must be a sequence or set.  For dicts, use list(d).")

        randbelow = self._randbelow

        n = len(population)

        if not 0 <= k <= n:

>           raise ValueError("Sample larger than population")

E           ValueError: Sample larger than population

../../../virtualenv/python3.5.6/lib/python3.5/random.py:324: ValueError

------------------------------ Captured log call -------------------------------

logging.py                 109 VERBOSE  https://wiki.musicbrainz.org redirected to https://wiki.musicbrainz.org/Main_Page

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://wiki.musicbrainz.org/Main_Page

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
Xqt triaged this task as High priority.Jan 25 2020, 12:53 PM

This seems to be caused by T130381 on MusicBrainz, second issue (wsbeta) is currently hidden by T243123

Change 573988 had a related patch set uploaded (by Dvorapa; owner: Dvorapa):
[pywikibot/core@master] [tests] Fix MusicBrainz sample number

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

Change 573988 merged by jenkins-bot:
[pywikibot/core@master] [tests] Fix MusicBrainz sample number

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

After last patch en:musicbrainz fails with the same issue as en:betawikisource.

______________ TestGenerateFamilyFiles.test_attributes_after_run _______________

self = <tests.generate_family_files_tests.TestGenerateFamilyFiles testMethod=test_attributes_after_run>

    def test_attributes_after_run(self):

        """Test FamilyFileGenerator attributes after run()."""

        gen = self.generator_instance

        gen.run()

    

        with self.subTest(test='Test whether default is loaded'):

            self.assertIn(self.site.lang, gen.wikis)

    

        with self.subTest(test='Test element counts'):

            if self.site.lang not in gen.prefixes:

                gen.prefixes += [self.site.lang]

>           self.assertCountEqual(gen.prefixes, gen.wikis)

E           AssertionError: Element counts were not equal:

E           First has 1, Second has 0:  'ab'

E           First has 1, Second has 0:  'lb'

tests/generate_family_files_tests.py:74: AssertionError

------------------------------ Captured log call -------------------------------

logging.py                 109 VERBOSE  https://wiki.musicbrainz.org redirected to https://wiki.musicbrainz.org/Main_Page

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://wiki.musicbrainz.org/Main_Page

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://acousticbrainz.org/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://listenbrainz.org/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

For comparison, current en:betawikisource fail:

______________ TestGenerateFamilyFiles.test_attributes_after_run _______________

self = <tests.generate_family_files_tests.TestGenerateFamilyFiles testMethod=test_attributes_after_run>

    def test_attributes_after_run(self):

        """Test FamilyFileGenerator attributes after run()."""

        gen = self.generator_instance

        gen.run()

    

        with self.subTest(test='Test whether default is loaded'):

            self.assertIn(self.site.lang, gen.wikis)

    

        with self.subTest(test='Test element counts'):

            if self.site.lang not in gen.prefixes:

                gen.prefixes += [self.site.lang]

>           self.assertCountEqual(gen.prefixes, gen.wikis)

E           AssertionError: Element counts were not equal:

E           First has 1, Second has 0:  'he'

E           First has 1, Second has 0:  'sr'

E           First has 1, Second has 0:  'crh'

E           First has 1, Second has 0:  'nl'

E           First has 1, Second has 0:  'es'

E           First has 1, Second has 0:  'aa'

E           First has 1, Second has 0:  'cs'

E           First has 1, Second has 0:  'hi'

E           First has 1, Second has 0:  'ko'

tests/generate_family_files_tests.py:74: AssertionError

------------------------------ Captured log call -------------------------------

logging.py                 109 VERBOSE  https://en.wikisource.beta.wmflabs.org redirected to https://en.wikisource.beta.wmflabs.org/wiki/Main_Page

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://en.wikisource.beta.wmflabs.org/wiki/Main_Page

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://he.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://sr.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://crh.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://nl.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://es.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://aa.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://cs.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://hi.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

logging.py                 109 WARNING  Http response status 404

logging.py                 109 VERBOSE  wgEnableApi is not enabled in HTML of https://ko.wikisource.beta.wmflabs.org/wiki/

logging.py                 109 VERBOSE  MW pre-1.17 detection failed: AttributeError("'NoneType' object has no attribute 'groups'",)

Okay, MusciBrainz is an issue with MediaWiki, but also requires small fix on MusicBrainz side.

Beta Cluster is not an issue as far as I can understand and Pywikibot should respect their choice to have interwiki to non-existing (HTTP 404) sites. In tests and perhaps also in generate_family_files.

Also we can fix both of them by creating special family file with corrections about such behavior.

Dvorapa renamed this task from Travis fails on generate_family_files_tests.TestGenerateFamilyFiles to Travis fails on generate_family_file_tests.TestGenerateFamilyFiles.Mar 20 2020, 1:36 PM
Dvorapa updated the task description. (Show Details)

Change 582027 had a related patch set uploaded (by Dvorapa; owner: Dvorapa):
[pywikibot/core@master] [tests] Skip some failing tests due to upstream issues

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

Change 582027 merged by jenkins-bot:
[pywikibot/core@master] [tests] Skip some failing tests due to upstream issues

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

Dvorapa lowered the priority of this task from High to Low.Mar 20 2020, 3:45 PM
Dvorapa moved this task from Test failures to Backlog on the Pywikibot-tests board.
Dvorapa moved this task from Backlog to Test failures on the Pywikibot-tests board.
Xqt claimed this task.
Xqt subscribed.

Haven't found this for a long time. MW pre-1.17 tests was dropped years ago. So I close it.