Page MenuHomePhabricator

some login tests fails due to TypeError
Closed, ResolvedPublic

Description

Some login tests fails due to TypeError: init() takes from 1 to 4 positional arguments but 5 were given.

The reason is that keyword arguments are invoked as positional aguments within tests.

=================================== FAILURES ===================================
______________________ TestOauthLoginManger.test_identity ______________________

self = <tests.oauth_tests.TestOauthLoginManger testMethod=test_identity>

    def test_identity(self):
        """Test identity."""
>       login_manager = self._get_login_manager()

tests/oauth_tests.py:77: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/oauth_tests.py:62: in _get_login_manager
    login_manager = OauthLoginManager(self.consumer_token[1], False,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

__args = (<pywikibot.login.OauthLoginManager object at 0x7fafde1fbbb0>, 'fe39000d3d114bf801e3a92b584a181cf38942f9', False, APISite("test", "wikipedia"), 'e0ef943a1890b04d656409e64641c0ba')
__kw = {}, name = 'pywikibot.login.OauthLoginManager.__init__', depth = 2
old_arg = 'sysop', new_arg = None
output_args = {'name': 'pywikibot.login.OauthLoginManager.__init__', 'new_arg': None, 'old_arg': 'sysop'}

    def wrapper(*__args, **__kw):
        """Replacement function.
    
        @param __args: args passed to the decorated function
        @param __kw: kwargs passed to the decorated function
        @return: the value returned by the decorated function
        @rtype: any
        """
        name = obj.__full_name__
        depth = get_wrapper_depth(wrapper) + 1
        for old_arg, new_arg in arg_pairs.items():
            output_args = {
                'name': name,
                'old_arg': old_arg,
                'new_arg': new_arg,
            }
            if old_arg in __kw:
                if new_arg not in [True, False, None]:
                    if new_arg in __kw:
                        warn('%(new_arg)s argument of %(name)s '
                             'replaces %(old_arg)s; cannot use both.'
                             % output_args,
                             RuntimeWarning, depth)
                    else:
                        # If the value is positionally given this will
                        # cause a TypeError, which is intentional
                        warn('%(old_arg)s argument of %(name)s '
                             'is deprecated; use %(new_arg)s instead.'
                             % output_args,
                             DeprecationWarning, depth)
                        __kw[new_arg] = __kw[old_arg]
                else:
                    if new_arg is False:
                        cls = PendingDeprecationWarning
                    else:
                        cls = DeprecationWarning
                    warn('%(old_arg)s argument of %(name)s is deprecated.'
                         % output_args,
                         cls, depth)
                del __kw[old_arg]
>       return obj(*__args, **__kw)
E       TypeError: __init__() takes from 1 to 4 positional arguments but 5 were given

pywikibot/tools/__init__.py:1744: TypeError
_______________________ TestOauthLoginManger.test_login ________________________

self = <tests.oauth_tests.TestOauthLoginManger testMethod=test_login>

    def test_login(self):
        """Test login."""
>       login_manager = self._get_login_manager()

tests/oauth_tests.py:70: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/oauth_tests.py:62: in _get_login_manager
    login_manager = OauthLoginManager(self.consumer_token[1], False,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

__args = (<pywikibot.login.OauthLoginManager object at 0x7fafde20aa30>, 'fe39000d3d114bf801e3a92b584a181cf38942f9', False, APISite("test", "wikipedia"), 'e0ef943a1890b04d656409e64641c0ba')
__kw = {}, name = 'pywikibot.login.OauthLoginManager.__init__', depth = 2
old_arg = 'sysop', new_arg = None
output_args = {'name': 'pywikibot.login.OauthLoginManager.__init__', 'new_arg': None, 'old_arg': 'sysop'}

    def wrapper(*__args, **__kw):
        """Replacement function.
    
        @param __args: args passed to the decorated function
        @param __kw: kwargs passed to the decorated function
        @return: the value returned by the decorated function
        @rtype: any
        """
        name = obj.__full_name__
        depth = get_wrapper_depth(wrapper) + 1
        for old_arg, new_arg in arg_pairs.items():
            output_args = {
                'name': name,
                'old_arg': old_arg,
                'new_arg': new_arg,
            }
            if old_arg in __kw:
                if new_arg not in [True, False, None]:
                    if new_arg in __kw:
                        warn('%(new_arg)s argument of %(name)s '
                             'replaces %(old_arg)s; cannot use both.'
                             % output_args,
                             RuntimeWarning, depth)
                    else:
                        # If the value is positionally given this will
                        # cause a TypeError, which is intentional
                        warn('%(old_arg)s argument of %(name)s '
                             'is deprecated; use %(new_arg)s instead.'
                             % output_args,
                             DeprecationWarning, depth)
                        __kw[new_arg] = __kw[old_arg]
                else:
                    if new_arg is False:
                        cls = PendingDeprecationWarning
                    else:
                        cls = DeprecationWarning
                    warn('%(old_arg)s argument of %(name)s is deprecated.'
                         % output_args,
                         cls, depth)
                del __kw[old_arg]
>       return obj(*__args, **__kw)
E       TypeError: __init__() takes from 1 to 4 positional arguments but 5 were given

pywikibot/tools/__init__.py:1744: TypeError

https://api.travis-ci.org/v3/job/607785508/log.txt

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
Xqt triaged this task as High priority.Nov 6 2019, 8:03 AM
Xqt updated the task description. (Show Details)

Change 548959 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Call OauthLoginManager with keyword arguments

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

Change 548959 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Call OauthLoginManager with keyword arguments

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

There are still some other tests failing:

=================================== FAILURES ===================================
______________________ TestOauthLoginManger.test_identity ______________________

self = <tests.oauth_tests.TestOauthLoginManger testMethod=test_identity>

    def test_identity(self):
        """Test identity."""
>       login_manager = self._get_login_manager()

tests/oauth_tests.py:78: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/oauth_tests.py:64: in _get_login_manager
    user=self.consumer_token[0])
pywikibot/tools/__init__.py:1744: in wrapper
    return obj(*__args, **__kw)
pywikibot/login.py:380: in __init__
    super(OauthLoginManager, self).__init__(None, False, site, None)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

__args = (<pywikibot.login.OauthLoginManager object at 0x7fc6f2aeffd0>, None, False, APISite("en", "wpbeta"), None)
__kw = {}, name = 'pywikibot.login.LoginManager.__init__', depth = 2
old_arg = 'sysop', new_arg = None
output_args = {'name': 'pywikibot.login.LoginManager.__init__', 'new_arg': None, 'old_arg': 'sysop'}

    def wrapper(*__args, **__kw):
        """Replacement function.
    
        @param __args: args passed to the decorated function
        @param __kw: kwargs passed to the decorated function
        @return: the value returned by the decorated function
        @rtype: any
        """
        name = obj.__full_name__
        depth = get_wrapper_depth(wrapper) + 1
        for old_arg, new_arg in arg_pairs.items():
            output_args = {
                'name': name,
                'old_arg': old_arg,
                'new_arg': new_arg,
            }
            if old_arg in __kw:
                if new_arg not in [True, False, None]:
                    if new_arg in __kw:
                        warn('%(new_arg)s argument of %(name)s '
                             'replaces %(old_arg)s; cannot use both.'
                             % output_args,
                             RuntimeWarning, depth)
                    else:
                        # If the value is positionally given this will
                        # cause a TypeError, which is intentional
                        warn('%(old_arg)s argument of %(name)s '
                             'is deprecated; use %(new_arg)s instead.'
                             % output_args,
                             DeprecationWarning, depth)
                        __kw[new_arg] = __kw[old_arg]
                else:
                    if new_arg is False:
                        cls = PendingDeprecationWarning
                    else:
                        cls = DeprecationWarning
                    warn('%(old_arg)s argument of %(name)s is deprecated.'
                         % output_args,
                         cls, depth)
                del __kw[old_arg]
>       return obj(*__args, **__kw)
E       TypeError: __init__() takes at most 4 arguments (5 given)

pywikibot/tools/__init__.py:1744: TypeError
_______________________ TestOauthLoginManger.test_login ________________________

self = <tests.oauth_tests.TestOauthLoginManger testMethod=test_login>

    def test_login(self):
        """Test login."""
>       login_manager = self._get_login_manager()

tests/oauth_tests.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/oauth_tests.py:64: in _get_login_manager
    user=self.consumer_token[0])
pywikibot/tools/__init__.py:1744: in wrapper
    return obj(*__args, **__kw)
pywikibot/login.py:380: in __init__
    super(OauthLoginManager, self).__init__(None, False, site, None)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

__args = (<pywikibot.login.OauthLoginManager object at 0x7fc6f2a03f50>, None, False, APISite("en", "wpbeta"), None)
__kw = {}, name = 'pywikibot.login.LoginManager.__init__', depth = 2
old_arg = 'sysop', new_arg = None
output_args = {'name': 'pywikibot.login.LoginManager.__init__', 'new_arg': None, 'old_arg': 'sysop'}

    def wrapper(*__args, **__kw):
        """Replacement function.
    
        @param __args: args passed to the decorated function
        @param __kw: kwargs passed to the decorated function
        @return: the value returned by the decorated function
        @rtype: any
        """
        name = obj.__full_name__
        depth = get_wrapper_depth(wrapper) + 1
        for old_arg, new_arg in arg_pairs.items():
            output_args = {
                'name': name,
                'old_arg': old_arg,
                'new_arg': new_arg,
            }
            if old_arg in __kw:
                if new_arg not in [True, False, None]:
                    if new_arg in __kw:
                        warn('%(new_arg)s argument of %(name)s '
                             'replaces %(old_arg)s; cannot use both.'
                             % output_args,
                             RuntimeWarning, depth)
                    else:
                        # If the value is positionally given this will
                        # cause a TypeError, which is intentional
                        warn('%(old_arg)s argument of %(name)s '
                             'is deprecated; use %(new_arg)s instead.'
                             % output_args,
                             DeprecationWarning, depth)
                        __kw[new_arg] = __kw[old_arg]
                else:
                    if new_arg is False:
                        cls = PendingDeprecationWarning
                    else:
                        cls = DeprecationWarning
                    warn('%(old_arg)s argument of %(name)s is deprecated.'
                         % output_args,
                         cls, depth)
                del __kw[old_arg]
>       return obj(*__args, **__kw)
E       TypeError: __init__() takes at most 4 arguments (5 given)

pywikibot/tools/__init__.py:1744: TypeError

Change 551866 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] call LoginManager with keyword arguments

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

Change 551866 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] call LoginManager with keyword arguments

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