Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1175558?usp=email )

Change subject: Tests: cover wrapper.run_python_file function which invokes 
scripts
......................................................................

Tests: cover wrapper.run_python_file function which invokes scripts

Bug: T401124
Change-Id: Id185d988069e533ef60b47eee3fcf6f96ec88bb8
---
M .github/workflows/pywikibot-ci.yml
M pywikibot/scripts/wrapper.py
2 files changed, 9 insertions(+), 0 deletions(-)

Approvals:
  Xqt: Verified; Looks good to me, approved




diff --git a/.github/workflows/pywikibot-ci.yml 
b/.github/workflows/pywikibot-ci.yml
index 46f51d8..f64cf69 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -130,6 +130,7 @@
         continue-on-error: true
         timeout-minutes: 90
         env:
+          COVERAGE_PROCESS_START: pyproject.toml
           PYWIKIBOT_TEST_NO_RC: ${{ (matrix.site == 'wikisource:zh' || 
matrix.test_no_rc) && 1 || 0 }}
         run: |
           python pwb.py version
diff --git a/pywikibot/scripts/wrapper.py b/pywikibot/scripts/wrapper.py
index d4b0081..656decb 100755
--- a/pywikibot/scripts/wrapper.py
+++ b/pywikibot/scripts/wrapper.py
@@ -125,6 +125,14 @@
     :param package: The package of the script. Used for checks.
     :type package: Optional[module]
     """
+    if os.environ.get('PYWIKIBOT_TEST_RUNNING', '0') == '1':
+        try:
+            import coverage
+        except ModuleNotFoundError:
+            pass
+        else:
+            coverage.process_startup()
+
     # Create a module to serve as __main__
     old_main_mod = sys.modules['__main__']
     main_mod = types.ModuleType('__main__')

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1175558?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: Id185d988069e533ef60b47eee3fcf6f96ec88bb8
Gerrit-Change-Number: 1175558
Gerrit-PatchSet: 3
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]

Reply via email to