Skip to content

Commit 998cc11

Browse files
committed
Tests: cover wrapper.run_python_file function which invokes scripts
Bug: T401124 Change-Id: Id185d988069e533ef60b47eee3fcf6f96ec88bb8
1 parent daad84a commit 998cc11

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.github/workflows/pywikibot-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ jobs:
130130
continue-on-error: true
131131
timeout-minutes: 90
132132
env:
133+
COVERAGE_PROCESS_START: pyproject.toml
133134
PYWIKIBOT_TEST_NO_RC: ${{ (matrix.site == 'wikisource:zh' || matrix.test_no_rc) && 1 || 0 }}
134135
run: |
135136
python pwb.py version

pywikibot/scripts/wrapper.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ def run_python_file(filename: str, args: list[str], package=None) -> None:
125125
:param package: The package of the script. Used for checks.
126126
:type package: Optional[module]
127127
"""
128+
if os.environ.get('PYWIKIBOT_TEST_RUNNING', '0') == '1':
129+
try:
130+
import coverage
131+
except ModuleNotFoundError:
132+
pass
133+
else:
134+
coverage.process_startup()
135+
128136
# Create a module to serve as __main__
129137
old_main_mod = sys.modules['__main__']
130138
main_mod = types.ModuleType('__main__')

0 commit comments

Comments
 (0)