Page MenuHomePhabricator

testNamespaceAliases fails on Travis
Closed, ResolvedPublic

Description

_______________ TestNonEnglishWikipediaSite.testNamespaceAliases _______________
self = <tests.site_tests.TestNonEnglishWikipediaSite testMethod=testNamespaceAliases>
    def testNamespaceAliases(self):
        """Test namespace aliases."""
        site = self.get_site()
    
        namespaces = site.namespaces
        image_namespace = namespaces[6]
        self.assertEqual(image_namespace.custom_name, 'Fil')
        self.assertEqual(image_namespace.canonical_name, 'File')
        self.assertEqual(str(image_namespace), ':File:')
        self.assertEqual(image_namespace.custom_prefix(), ':Fil:')
        self.assertEqual(image_namespace.canonical_prefix(), ':File:')
>       self.assertEqual(image_namespace.aliases, ['Image'])
E       AssertionError: Lists differ: [u'Image', u'Bilde'] != [u'Image']
E       
E       First list contains 1 additional elements.
E       First extra element 1:
E       Bilde
E       
E       - [u'Image', u'Bilde']
E       + [u'Image']
tests/site_tests.py:2441: AssertionError

see: https://travis-ci.org/wikimedia/pywikibot-core/jobs/190337445#L3982

Event Timeline

@Magul, it seems that you've found the cause. May I upload a patch adding 'Bilde' to the test or are you planning to do more investigation and upload the patch later?

I was going create this patch, but You're welcome to do it also, I will just review it (remember about sorting list).

remember about sorting list

Sorry, I don't know which part of the code you're referring to, do you mean that image_namespace.aliases should be sorted? Because AFAIS, the current code always adds 'Bilde' after the image (no need to sort aliases).

Anyway, I'll send the patch, it'll probably be easier to discuss it on gerrit.

Change 331839 had a related patch set uploaded (by Dalba):
Add 'Bilde' as a namespace alias for file namespace of nn Wikipedia

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

Could be interesting to mock API replies with a known standard value, as the goal is to test the pywikibot parsing capabilities, not what some Wikimedia project MediaWiki API decides to reply today.

@Dereckson You have my full support on that. Actually we right now have little (or no) unittests in pywikibot and I would like to change it.

Right now lot of tests are in fact integration tests, but before adding proper unittests I'm trying to make our Travis CI to pass all tests.

(And I actually see value in running integration tests.)

Change 331839 merged by jenkins-bot:
Add 'Bilde' as a namespace alias for file namespace of nn Wikipedia

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