jenkins-bot has submitted this change and it was merged.
Change subject: nosetests does not honour PYWIKIBOT2_TEST_AUTORUN
......................................................................
nosetests does not honour PYWIKIBOT2_TEST_AUTORUN
Autorun scripts aren't added to the tested methods in
script_tests.collector, however the collector isn't always used by
nosetests.
Autorun scripts run a tests which skips them if PYWIKIBOT2_TEST_AUTORUN
is set.
Bug: T95385
Change-Id: Ibbaa684588a9b46e10a86611bfc248c9ce11ac0f
---
M tests/script_tests.py
1 file changed, 14 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 1ba6bfb..d6b97d7 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -163,14 +163,15 @@
no_args_expected_results['replicate_wiki'] = 'error: too few
arguments'
+enable_autorun_tests = (
+ os.environ.get('PYWIKIBOT2_TEST_AUTORUN', '0') == '1')
+
+
def collector(loader=unittest.loader.defaultTestLoader):
"""Load the default tests."""
# Note: Raising SkipTest during load_tests will
# cause the loader to fallback to its own
# discover() ordering of unit tests.
-
- enable_autorun_tests = (
- os.environ.get('PYWIKIBOT2_TEST_AUTORUN', '0') == '1')
if deadlock_script_list:
print('Skipping deadlock scripts:\n %s'
@@ -222,6 +223,13 @@
def __new__(cls, name, bases, dct):
"""Create the new class."""
def test_execution(script_name, args=[], expected_results=None):
+ is_autorun = '-help' not in args and script_name in
auto_run_script_list
+
+ def test_skip_script(self):
+ raise unittest.SkipTest(
+ 'Skipping execution of auto-run scripts (set '
+ 'PYWIKIBOT2_TEST_AUTORUN=1 to enable)
"{0}"'.format(script_name))
+
def testScript(self):
cmd = [script_name]
@@ -231,7 +239,7 @@
data_in = script_input.get(script_name)
timeout = 0
- if '-help' not in args and script_name in auto_run_script_list:
+ if is_autorun:
timeout = 5
if expected_results and script_name in expected_results:
@@ -306,6 +314,8 @@
sys.stdout.flush()
+ if not enable_autorun_tests and is_autorun:
+ return test_skip_script
return testScript
for script_name in script_list:
--
To view, visit
https://gerrit.wikimedia.org/r/207112
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibbaa684588a9b46e10a86611bfc248c9ce11ac0f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>