Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1223149?usp=email )
Change subject: doc: Update tests documentation ......................................................................
doc: Update tests documentation
Also - shorten TEST_RUNNING usage in login.py - remove unused ci_test_run variable in script_tests.py
Change-Id: I6455a42f0bd0b30b31d55d19a0dd20785ba65e4f --- M pywikibot/login.py M tests/README.rst M tests/script_tests.py 3 files changed, 7 insertions(+), 10 deletions(-)
Approvals: Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/login.py b/pywikibot/login.py index 4565fec..d4008ba 100644 --- a/pywikibot/login.py +++ b/pywikibot/login.py @@ -1,6 +1,6 @@ """Library to log the bot in to a wiki account.""" # -# (C) Pywikibot team, 2003-2025 +# (C) Pywikibot team, 2003-2026 # # Distributed under the terms of the MIT license. # @@ -243,9 +243,8 @@ password_path = Path(config.password_file)
# ignore this check when running tests - if os.environ.get('PYWIKIBOT_TEST_RUNNING', '0') == '0' \ - and (not password_path.is_file(**params) - or password_path.is_symlink()): + if not TEST_RUNNING and (not password_path.is_file(**params) + or password_path.is_symlink()): raise FileNotFoundError( f'Password file {password_path.name} does not exist in ' f'{password_path.parent}' diff --git a/tests/README.rst b/tests/README.rst index 503b397..b8a61fc 100644 --- a/tests/README.rst +++ b/tests/README.rst @@ -124,10 +124,10 @@ PYWIKIBOT_TEST_QUIET=1
**PYWIKIBOT_TEST_RUNNING** - This environment variable skips tests instead of raising + This environment variable ignores some passwordfile checks in + :meth:`login.LoginManager.readPassword` and skips some tests instead of raising :exc:`exceptions.MaxlagTimeoutError` when maximum retries attempted due to - maxlag without success. It is also used by :source:`tests/script_tests` for code - coverage. GitHub actions and AppVeyor tests activate this variable:: + maxlag without success. GitHub actions and Jenkins tests activate this variable::
PYWIKIBOT_TEST_RUNNING=1
diff --git a/tests/script_tests.py b/tests/script_tests.py index 91fb74a..95803b0 100755 --- a/tests/script_tests.py +++ b/tests/script_tests.py @@ -1,13 +1,12 @@ #!/usr/bin/env python3 """Test that each script can be compiled and executed.""" # -# (C) Pywikibot team, 2014-2025 +# (C) Pywikibot team, 2014-2026 # # Distributed under the terms of the MIT license. # from __future__ import annotations
-import os import sys import unittest from collections.abc import Iterator @@ -21,7 +20,6 @@ from tests.utils import execute_pwb
-ci_test_run = os.environ.get('PYWIKIBOT_TEST_RUNNING', '0') == '1' scripts_path = join_root_path('scripts')
# login script should be the first to test
pywikibot-commits@lists.wikimedia.org