jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/637853 )
Change subject: [bugfix] Fix create_simple in test environment ......................................................................
[bugfix] Fix create_simple in test environment
api.Request.create_simple has as a positional argument "req_site" (positional-only would be nice here) but the test implementations doesn't and requires the parameter as keyword argument.
- Fix create_simple in tests/__init__.py and tests/utils.py - Fix create_simple in CachedRequest - Make a keyworded call for Request in api.create_simple - Update T262926 hint
Bug: T262926 Change-Id: Ie70f83ee1c6cc002177dc0a02b27558915406e7c --- M pywikibot/data/api.py M tests/__init__.py M tests/utils.py 3 files changed, 7 insertions(+), 8 deletions(-)
Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 9f2122d..e039b8a 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1186,12 +1186,12 @@ # This ONLY support site so that any caller can be sure there will be # no conflict with PWB parameters # req_site is needed to avoid conflicts with possible site keyword in - # kwarg, see T262926 + # kwarg until positional-only parameters are supported, see T262926 # TODO: Use ParamInfo request to determine valid parameters if isinstance(kwargs.get('parameters'), dict): warn('The request contains already a "parameters" entry which is ' 'a dict.') - return cls(req_site, parameters=kwargs) + return cls(site=req_site, parameters=kwargs)
@classmethod def _warn_both(cls): @@ -2020,7 +2020,7 @@ self._cachetime = None
@classmethod - def create_simple(cls, site, **kwargs): + def create_simple(cls, req_site, **kwargs): """Unsupported as it requires at least two parameters.""" raise NotImplementedError('CachedRequest cannot be created simply.')
diff --git a/tests/__init__.py b/tests/__init__.py index b762659..f313e60 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -290,10 +290,9 @@ super().__init__(0, *args, **kwargs)
@classmethod - def create_simple(cls, **kwargs): + def create_simple(cls, req_site, **kwargs): """Circumvent CachedRequest implementation.""" - site = kwargs.pop('site') - return cls(site=site, parameters=kwargs) + return cls(site=req_site, parameters=kwargs)
def _expired(self, dt): """Never invalidate cached data.""" diff --git a/tests/utils.py b/tests/utils.py index 9db82d4..3c12e3b 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -314,9 +314,9 @@ _original_Request.__init__(self, *args, **kwargs)
@classmethod - def create_simple(cls, **kwargs): + def create_simple(cls, req_site, **kwargs): """Skip CachedRequest implementation.""" - return _original_Request.create_simple(**kwargs) + return _original_Request.create_simple(req_site, **kwargs)
def _expired(self, dt): """Never invalidate cached data."""
pywikibot-commits@lists.wikimedia.org