jenkins-bot has submitted this change and it was merged.
Change subject: Split script tests into help and simulate tests
......................................................................
Split script tests into help and simulate tests
List 'version' as an unrunable script, as it does
not support global options.
Four auto-run scripts are moved from expected failures
to be allowed failures, as their output is highly
variable depending on existence of site templates or
categories, and may not emit output within the time
given on wikis with large backlogs.
Change-Id: I7f29107f2d4db5e6c639f349e83ce4705d478034
---
M tests/script_tests.py
M tests/utils.py
2 files changed, 91 insertions(+), 61 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 78a6c34..f7938cd 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -11,8 +11,6 @@
import os
import sys
-from pywikibot import config
-
from tests import _root_dir
from tests.aspects import unittest, DefaultSiteTestCase, MetaTestCaseClass, PwbTestCase
from tests.utils import allowed_failure, execute_pwb, add_metaclass
@@ -63,6 +61,7 @@
if not check_script_deps(name)]
unrunnable_script_list = [
+ 'version', # does not use global args
'script_wui', # depends on lua compiling
]
@@ -145,7 +144,6 @@
'spamremove': 'No spam site specified',
'transferbot': 'Target site not different from source site', # Bug 68662
'unusedfiles': ('Working on', None),
- 'version': 'unicode test: ',
'watchlist': 'Retrieving watchlist',
# The following auto-run and typically cant be validated,
@@ -180,21 +178,27 @@
'(set PYWIKIBOT2_TEST_AUTORUN=1 to enable):\n %r'
% auto_run_script_list)
- tests = (['test__login_help'] +
- ['test_' + name + '_help'
+ tests = (['test__login'] +
+ ['test_' + name
for name in sorted(script_list)
- if name != 'login'] +
- ['test__login_simulate'])
+ if name != 'login' and
+ name not in unrunnable_script_list
+ ])
- tests += ['test_' + name + '_simulate'
+ test_list = ['tests.script_tests.TestScriptHelp.' + name
+ for name in tests]
+
+ tests = (['test__login'] +
+ ['test_' + name
for name in sorted(script_list)
if name != 'login' and
name not in failed_dep_script_list and
name not in unrunnable_script_list and
- (enable_autorun_tests or name not in auto_run_script_list)]
+ (enable_autorun_tests or name not in auto_run_script_list)
+ ])
- test_list = ['tests.script_tests.TestScript.' + name
- for name in tests]
+ test_list += ['tests.script_tests.TestScriptSimulate.' + name
+ for name in tests]
tests = loader.loadTestsFromNames(test_list)
suite = unittest.TestSuite()
@@ -214,7 +218,7 @@
def __new__(cls, name, bases, dct):
"""Create the new class."""
- def test_execution(script_name, args=[], expected_results=None):
+ def test_execution(script_name, args=[]):
is_autorun = '-help' not in args and script_name in auto_run_script_list
def test_skip_script(self):
@@ -234,8 +238,8 @@
if is_autorun:
timeout = 5
- if expected_results and script_name in expected_results:
- error = expected_results[script_name]
+ if self._results and script_name in self._results:
+ error = self._results[script_name]
if isinstance(error, basestring):
stdout = None
else:
@@ -244,7 +248,12 @@
stdout = None
error = None
- result = execute_pwb(cmd, data_in, timeout=timeout, error=error)
+ test_overrides = {}
+ if not hasattr(self, 'net') or not self.net:
+ test_overrides['pywikibot.Site'] = 'None'
+
+ result = execute_pwb(cmd, data_in, timeout=timeout, error=error,
+ overrides=test_overrides)
stderr = result['stderr'].split('\n')
stderr_sleep = [l for l in stderr
@@ -307,6 +316,8 @@
return test_skip_script
return testScript
+ argument = dct['_argument']
+
for script_name in script_list:
# force login to be the first, alphabetically, so the login
# message does not unexpectedly occur during execution of
@@ -314,66 +325,51 @@
# unrunnable script tests are disabled by default in load_tests()
if script_name == 'login':
- test_name = 'test__' + script_name + '_help'
+ test_name = 'test__login'
else:
- test_name = 'test_' + script_name + '_help'
+ test_name = 'test_' + script_name
+
# it's explicitly using str() because __name__ must be str
test_name = str(test_name)
- dct[test_name] = test_execution(script_name, ['-help'])
- if script_name in ['version',
- 'script_wui', # Failing on travis-ci
- ] + failed_dep_script_list:
- dct[test_name] = unittest.expectedFailure(dct[test_name])
- dct[test_name].__doc__ = 'Test running ' + script_name + ' -help'
- dct[test_name].__name__ = test_name
+ dct[test_name] = test_execution(script_name, ['-' + argument])
- # Ideally all scripts should execute -help without
- # connecting to a site.
- # TODO: after bug 68611 and 68664 (and makecat), split -help
- # execution to a separate test class which uses site=False.
-
- if script_name == 'login':
- test_name = 'test__' + script_name + '_simulate'
- else:
- test_name = 'test_' + script_name + '_simulate'
- # it's explicitly using str() because __name__ must be str
- test_name = str(test_name)
- dct[test_name] = test_execution(script_name, ['-simulate'],
- no_args_expected_results)
- if script_name in ['catall', # stdout user interaction
- 'flickrripper', # Requires a flickr api key
- 'script_wui', # Error on any user except DrTrigonBot
- 'upload', # raises custom ValueError
- ] + failed_dep_script_list or (
- (config.family == 'wikipedia' and script_name == 'disambredir') or
- (config.family != 'wikidata' and script_name == 'checkimages') or
- (config.family == 'wikipedia' and config.mylang != 'en' and script_name == 'misspelling')): # T94681
+ if script_name in dct['_expected_failures']:
dct[test_name] = unittest.expectedFailure(dct[test_name])
- elif script_name in ['watchlist', # T77965
- 'lonelypages', # uses exit code 1; T94680
- ]:
+ elif script_name in dct['_allowed_failures']:
dct[test_name] = allowed_failure(dct[test_name])
- dct[test_name].__doc__ = \
- 'Test running ' + script_name + ' -simulate.'
+
+ dct[test_name].__doc__ = 'Test running %s -%s.' % (script_name,
+ argument)
dct[test_name].__name__ = test_name
# Disable test by default in nosetests
if script_name in unrunnable_script_list:
dct[test_name].__test__ = False
- # TODO: Ideally any script not on the auto_run_script_list
- # can be set as 'not a site' test, but that will require
- # auditing all code in main() to ensure it exits without
- # connecting to a site. There are outstanding bugs about
- # connections during initialisation.
- #
- # dct[test_name].site = True
-
return super(TestScriptMeta, cls).__new__(cls, name, bases, dct)
@add_metaclass
-class TestScript(DefaultSiteTestCase, PwbTestCase):
+class TestScriptHelp(PwbTestCase):
+
+ """Test cases for running scripts with -help.
+
+ All scripts should not create a Site for -help, so net = False.
+ """
+
+ __metaclass__ = TestScriptMeta
+
+ net = False
+
+ _expected_failures = failed_dep_script_list
+ _allowed_failures = []
+
+ _argument = 'help'
+ _results = None
+
+
+@add_metaclass
+class TestScriptSimulate(DefaultSiteTestCase, PwbTestCase):
"""Test cases for scripts.
@@ -387,6 +383,26 @@
user = True
+ _expected_failures = [
+ 'catall', # stdout user interaction
+ 'flickrripper', # Requires a flickr api key
+ 'upload', # raises custom ValueError
+ ] + failed_dep_script_list
+
+ _allowed_failures = [
+ 'checkimages',
+ 'disambredir',
+ # T94681
+ 'misspelling',
+ # T77965
+ 'watchlist',
+ # T94680: uses exit code 1
+ 'lonelypages',
+ ]
+
+ _argument = 'simulate'
+ _results = no_args_expected_results
+
if __name__ == '__main__':
try:
diff --git a/tests/utils.py b/tests/utils.py
index 435545f..27152da 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -512,12 +512,26 @@
'stderr': (stderr_lines + data_out[1]).decode(config.console_encoding)}
-def execute_pwb(args, data_in=None, timeout=0, error=None):
+def execute_pwb(args, data_in=None, timeout=0, error=None, overrides=None):
"""
Execute the pwb.py script and capture outputs.
@param args: list of arguments for pwb.py
@type args: list of unicode
+ @param overrides: mapping of pywikibot symbols to test replacements
+ @type overrides: dict
"""
- return execute(command=[sys.executable, _pwb_py] + args,
+ command = [sys.executable]
+
+ if overrides:
+ command.append('-c')
+ overrides = '; '.join(
+ '%s = %s' % (key, value) for key, value in overrides.items())
+ command.append(
+ 'import pwb; import pywikibot; %s; pwb.main()'
+ % overrides)
+ else:
+ command.append(_pwb_py)
+
+ return execute(command=command + args,
data_in=data_in, timeout=timeout, error=error)
--
To view, visit https://gerrit.wikimedia.org/r/216408
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7f29107f2d4db5e6c639f349e83ce4705d478034
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
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 <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2550
Status: Passed
Duration: 24 minutes and 45 seconds
Commit: 00eb20f (master)
Author: Fabian Neundorf
Message: [IMPROV] script_test: Simplify test for stderr
If there is expected output for that script it should just check that. The
additional check if it's an autorun script are unnecessary. The same is true
for the reverse and if there is no expected output and it is not an autorun
script then it should do the checks related to that.
Change-Id: Ic40aee0b1975ad1f785f27bafd3e56bc09511ada
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/bce6abffe55a...00eb20fb…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/71443564
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] script_test: Simplify test for stderr
......................................................................
[IMPROV] script_test: Simplify test for stderr
If there is expected output for that script it should just check that. The
additional check if it's an autorun script are unnecessary. The same is true
for the reverse and if there is no expected output and it is not an autorun
script then it should do the checks related to that.
Change-Id: Ic40aee0b1975ad1f785f27bafd3e56bc09511ada
---
M tests/script_tests.py
1 file changed, 10 insertions(+), 13 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 68d6b17..78a6c34 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -257,21 +257,18 @@
if result['exit_code'] == -9:
print(' killed', end=' ')
- if '-help' in args or error or \
- script_name not in auto_run_script_list:
+ if error:
+ self.assertIn(error, result['stderr'])
- if error:
- self.assertIn(error, result['stderr'])
+ exit_codes = [0, 1, 2, -9]
+ elif not is_autorun:
+ if stderr_other == ['']:
+ stderr_other = None
+ self.assertIsNone(stderr_other)
+ self.assertIn('Global arguments available for all',
+ result['stdout'])
- exit_codes = [0, 1, 2, -9]
- else:
- if stderr_other == ['']:
- stderr_other = None
- self.assertIsNone(stderr_other)
- self.assertIn('Global arguments available for all',
- result['stdout'])
-
- exit_codes = [0]
+ exit_codes = [0]
else:
# auto-run
exit_codes = [0, -9]
--
To view, visit https://gerrit.wikimedia.org/r/225315
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic40aee0b1975ad1f785f27bafd3e56bc09511ada
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: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2549
Status: Fixed
Duration: 25 minutes and 5 seconds
Commit: bce6abf (master)
Author: VcamX
Message: Remove unnecessary command args in execute_pwb
The additional command args were introduced by T98671 to depress unexpected
DeprecationWarning on Python <2.7.9, which is now fixed by T103769.
Change-Id: I23b682741f53687ddf3e36274d97cde5759e040a
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/2ad0dd765900...bce6abff…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/71366667
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: Remove dependency on pYsearch
......................................................................
Remove dependency on pYsearch
pYsearch does not work, and an alternative implementation
is not yet available.
Bug: T106062
Bug: T106085
Change-Id: I162cc2cc125dc894d8a05ca711577dc37af5dcb2
---
M pywikibot/config2.py
M pywikibot/pagegenerators.py
M requirements.txt
M setup.py
4 files changed, 6 insertions(+), 8 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 0acc717..bd541a6 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -613,9 +613,8 @@
# ############# SEARCH ENGINE SETTINGS ##############
-# Some scripts allow using the Yahoo! Search Web Services. To use this feature,
-# you must install the pYsearch module from http://pysearch.sourceforge.net
-# and get a Yahoo AppID from https://developer.yahoo.com/
+# Yahoo! Search Web Services are not operational.
+# See https://phabricator.wikimedia.org/T106085
yahoo_appid = ''
# To use Windows Live Search web service you must get an AppID from
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 4fe6fad..7971750 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -2118,7 +2118,6 @@
To use this generator, install pYsearch
"""
- # values larger than 100 fail
@deprecated_args(count='total')
def __init__(self, query=None, total=100, site=None):
"""
@@ -2127,6 +2126,10 @@
@param site: Site for generator results.
@type site: L{pywikibot.site.BaseSite}
"""
+ raise RuntimeError(
+ 'pagegenerator YahooSearchPageGenerator is not functional.\n'
+ 'See https://phabricator.wikimedia.org/T106085')
+
self.query = query or pywikibot.input(u'Please enter the search query:')
self.total = total
if site is None:
diff --git a/requirements.txt b/requirements.txt
index e2b14dd..e0f5a1f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -44,9 +44,6 @@
Pillow
# core pagegenerators
---allow-external pYsearch
---allow-unverified pYsearch
-pYsearch ; python_version < '3'
google >= 1.7
socketIO-client<0.6.1
diff --git a/setup.py b/setup.py
index b65277b..c07fdbe 100644
--- a/setup.py
+++ b/setup.py
@@ -35,7 +35,6 @@
extra_deps.update({
'csv': ['unicodecsv'],
'MySQL': ['oursql'],
- 'Yahoo': ['pYsearch'],
})
script_deps = {
--
To view, visit https://gerrit.wikimedia.org/r/225219
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I162cc2cc125dc894d8a05ca711577dc37af5dcb2
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>