jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1172810?usp=email )
Change subject: Tests: ignore create_isbn_edition from script_tests
......................................................................
Tests: ignore create_isbn_edition from script_tests
Also refactor ist_scripts function using pathlib;
exclude must not contain .py suffix anymore.
Bug: T398140
Change-Id: I76015f105c9d5af0e1bc4c5008b3bf1660c27ff5
---
M tests/script_tests.py
1 file changed, 19 insertions(+), 8 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 19e4eed..ecf871e 100755
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -12,6 +12,7 @@
import unittest
from contextlib import suppress
from importlib import import_module
+from pathlib import Path
from pywikibot.tools import has_module
from tests import join_root_path, unittest_print
@@ -28,7 +29,6 @@
# These dependencies are not always the package name which is in setup.py.
# Here, the name given to the module which will be imported is required.
script_deps = {
- 'create_isbn_edition': ['isbnlib', 'unidecode'],
'weblinkchecker': ['memento_client'],
}
@@ -51,17 +51,28 @@
unrunnable_script_set = set()
-def list_scripts(path, exclude=None):
- """Return list of scripts in given path."""
+def list_scripts(path: str, exclude: str = '') -> list[str]:
+ """List script names (without '.py') in a directory.
+
+ :param path: Directory path to search for Python scripts.
+ :param exclude: Filename (without '.py' extension) to exclude from
+ the result. Defaults to empty string, meaning no exclusion.
+ :return: List of script names without the '.py' extension, excluding
+ the specified file. Files starting with '_' (e.g. __init__.py)
+ are always excluded.
+ """
+ p = Path(path)
return [
- name[0:-3] for name in os.listdir(path) # strip '.py'
- if name.endswith('.py')
- and not name.startswith('_') # skip __init__.py and _*
- and name != exclude
+ f.stem for f in p.iterdir()
+ if f.is_file()
+ and f.suffix == '.py'
+ and not f.name.startswith('_')
+ and f.stem != exclude
]
-script_list = framework_scripts + list_scripts(scripts_path)
+script_list = framework_scripts + list_scripts(scripts_path,
+ 'create_isbn_edition')
script_input = {
'create_isbn_edition': '\n',
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1172810?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I76015f105c9d5af0e1bc4c5008b3bf1660c27ff5
Gerrit-Change-Number: 1172810
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]