jenkins-bot submitted this change.

View Change


Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified
[cleanup] remove unused error parameter in utils.execute

- also remove error parameter in utils.execute_pwb and
PwbTestCase._execute() which are no longer needed

Bug: T335241
Change-Id: I4936c295e2ecc68c5c41958951daae8d2693e326
---
M tests/script_tests.py
M tests/utils.py
M tests/aspects.py
3 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/tests/aspects.py b/tests/aspects.py
index ba8cc36..d3ebde0 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -1331,12 +1331,12 @@
if self.orig_pywikibot_dir:
os.environ['PYWIKIBOT_DIR'] = self.orig_pywikibot_dir

- def _execute(self, args, data_in=None, timeout=None, error=None):
+ def _execute(self, args, data_in=None, timeout=None):
site = self.get_site()

args += ['-family:' + site.family.name, '-lang:' + site.code]

- return execute_pwb(args, data_in, timeout, error)
+ return execute_pwb(args, data_in, timeout)


class RecentChangesTestCase(WikimediaDefaultSiteTestCase):
diff --git a/tests/script_tests.py b/tests/script_tests.py
index d4e174d..0e9a8c8 100755
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -223,7 +223,7 @@

# run the script
result = execute_pwb(cmd, data_in, timeout=timeout,
- error=error, overrides=test_overrides)
+ overrides=test_overrides)

err_result = result['stderr']
out_result = result['stdout']
diff --git a/tests/utils.py b/tests/utils.py
index 5a49e16..b7fc747 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -11,16 +11,17 @@
import warnings
from contextlib import contextmanager
from subprocess import PIPE, Popen, TimeoutExpired
-from typing import Optional
+from typing import Any, Optional, Union

import pywikibot
from pywikibot import config
-from pywikibot.backports import List
+from pywikibot.backports import Dict, List, Sequence
from pywikibot.data.api import CachedRequest
from pywikibot.data.api import Request as _original_Request
from pywikibot.exceptions import APIError
from pywikibot.login import LoginStatus
from pywikibot.site import Namespace
+
from tests import _pwb_py


@@ -451,9 +452,11 @@
"""Ignore password changes."""


-def execute(command: List[str], data_in=None, timeout=None, error=None):
- """
- Execute a command and capture outputs.
+def execute(command: List[str], data_in=None, timeout=None):
+ """Execute a command and capture outputs.
+
+ .. versionchanged:: 8.2.0
+ *error* parameter was removed.

:param command: executable to run and arguments to use
"""
@@ -495,14 +498,17 @@
'stderr': stderr_data.decode(config.console_encoding)}


-def execute_pwb(args, data_in=None, timeout=None, error=None, overrides=None):
- """
- Execute the pwb.py script and capture outputs.
+def execute_pwb(args: List[str],
+ data_in: Optional[Sequence[str]] = None,
+ timeout: Union[int, float, None] = None,
+ overrides: Optional[Dict[str, str]] = None) -> Dict[str, Any]:
+ """Execute the pwb.py script and capture outputs.
+
+ .. versionchanged:: 8.2.0
+ the *error* parameter was removed.

:param args: list of arguments for pwb.py
- :type args: typing.Sequence[str]
:param overrides: mapping of pywikibot symbols to test replacements
- :type overrides: dict
"""
command = [sys.executable]

@@ -511,13 +517,11 @@
overrides = '; '.join(
f'{key} = {value}' for key, value in overrides.items())
command.append(
- 'import pwb; import pywikibot; {}; pwb.main()'
- .format(overrides))
+ f'import pwb; import pywikibot; {overrides}; pwb.main()')
else:
command.append(_pwb_py)

- return execute(command=command + args,
- data_in=data_in, timeout=timeout, error=error)
+ return execute(command=command + args, data_in=data_in, timeout=timeout)


@contextmanager

To view, visit change 910860. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I4936c295e2ecc68c5c41958951daae8d2693e326
Gerrit-Change-Number: 910860
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged