Page MenuHomePhabricator

test_login_logout fails on my Travis CI account
Closed, ResolvedPublic

Description

https://travis-ci.org/5j9/pywikibot-core/jobs/558833475#L1228

______________________ TestLoginLogout.test_login_logout _______________________
self = <tests.site_tests.TestLoginLogout testMethod=test_login_logout>
    @unittest.skipIf(os.environ.get('APPVEYOR', 'false') in ('true', 'True'),
                     'No user defined for APPVEYOR tests')
    def test_login_logout(self):
        """Validate login and logout methods by toggling the state."""
        site = self.get_site()
        loginstatus = pywikibot.site.LoginStatus
    
        self.assertFalse(site.logged_in())
        self.assertEqual(site._loginstatus, loginstatus.NOT_ATTEMPTED)
    
>       site.login()
tests/site_tests.py:3673: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pywikibot/site.py:2089: in login
    if login_manager.login(retry=True, autocreate=autocreate):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <pywikibot.data.api.LoginManager object at 0x7f4fed2cc4d0>, retry = True
autocreate = False
    def login(self, retry=False, autocreate=False):
        """
        Attempt to log into the server.
    
        @see: U{https://www.mediawiki.org/wiki/API:Login}
    
        @param retry: infinitely retry if the API returns an unknown error
        @type retry: bool
    
        @param autocreate: if true, allow auto-creation of the account
                           using unified login
        @type autocreate: bool
    
        @raises NoUsername: Username is not recognised by the site.
        """
        if not self.password:
            # First check that the username exists,
            # to avoid asking for a password that will not work.
            if not autocreate:
                self.check_user_exists()
    
            # As we don't want the password to appear on the screen, we set
            # password = True
            self.password = pywikibot.input(
                'Password for user %(name)s on %(site)s (no characters will '
                'be shown):' % {'name': self.login_name, 'site': self.site},
                password=True)
    
        pywikibot.output('Logging in to %(site)s as %(name)s'
                         % {'name': self.login_name, 'site': self.site})
        try:
            cookiedata = self.getCookie()
        except pywikibot.data.api.APIError as e:
            error_code = e.code
            pywikibot.error('Login failed ({}).'.format(error_code))
            if error_code in self._api_error:
                error_msg = 'Username "{}" {} on {}'.format(
                    self.login_name, self._api_error[error_code], self.site)
                if error_code == 'Failed':
                    error_msg += '\n.{}'.format(e.info)
>               raise NoUsername(error_msg)
E               NoUsername: Username "Test20180327" does not have read permissions on wpbeta:en
E               .You have made too many recent login attempts. Please wait 5 minutes before trying again.

.travis.yml does not insert any username entries for wpbeta in the user-confit.py. Therefore I think this test should not have been run on this site.

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript

Change 523169 had a related patch set uploaded (by Dalba; owner: dalba):
[pywikibot/core@master] test(TestLoginLogout): mark as a user test

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

Change 523169 merged by jenkins-bot:
[pywikibot/core@master] test(TestLoginLogout): mark as a user test

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

Dalba claimed this task.