jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/778663 )
Change subject: [tests] enable coverage for script_tests and update codecov.yml ......................................................................
[tests] enable coverage for script_tests and update codecov.yml
Change-Id: I3149d1edde7df06d1a9a82b2a1b828e8b55c0b48 --- M .codecov.yml M tests/script_tests.py 2 files changed, 18 insertions(+), 1 deletion(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/.codecov.yml b/.codecov.yml index 984987a..a9c9253 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,7 +1,9 @@ codecov: - bot: jayvdb + bot: xqt
coverage: + round: up + range: 75..95 status: project: default: diff --git a/tests/script_tests.py b/tests/script_tests.py index 5669603..2ab29cd 100755 --- a/tests/script_tests.py +++ b/tests/script_tests.py @@ -9,6 +9,7 @@ import sys import unittest from contextlib import suppress +from importlib import import_module
from pywikibot.tools import has_module from tests import join_root_path, unittest_print @@ -16,6 +17,7 @@ from tests.utils import execute_pwb
+ci_test_run = os.environ.get('PYWIKIBOT_TESTS_RUNNING', '0') == '1' scripts_path = join_root_path('scripts') framework_scripts = ['shell']
@@ -193,6 +195,17 @@ return collector(loader)
+def import_script(script_name: str): + """Import script for coverage only (T305795).""" + if not ci_test_run: + return + if script_name in framework_scripts: + prefix = 'pywikibot.scripts.' + else: + prefix = 'scripts.' + import_module(prefix + script_name) + + class TestScriptMeta(MetaTestCaseClass):
"""Test meta class.""" @@ -307,6 +320,8 @@ arguments = dct['_arguments']
for script_name in script_list: + import_script(script_name) + # force login to be the first, alphabetically, so the login # message does not unexpectedly occur during execution of # another script.
pywikibot-commits@lists.wikimedia.org