jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/474469 )
Change subject: [PEP8] Fix W504 errors in pywikibot/tests
......................................................................
[PEP8] Fix W504 errors in pywikibot/tests
Fixed the W504 error occurrences in the following files:
- tests/aspects.py
- tests/dry_api_tests.py
- tests/script_tests.py
Bug: T207836
Change-Id: I6f487498539a2f204ef02b47f3417dc2ba50f721
---
M tests/aspects.py
M tests/dry_api_tests.py
M tests/script_tests.py
3 files changed, 46 insertions(+), 46 deletions(-)
Approvals:
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 0237885..5fcf8db 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -226,8 +226,8 @@
if skip and set(page_namespaces) != namespaces:
raise unittest.SkipTest('Pages in namespaces {!r} not found.'
- .format(list(namespaces -
- set(page_namespaces))))
+ .format(list(namespaces
+ - set(page_namespaces))))
else:
self.assertEqual(set(page_namespaces), namespaces)
@@ -333,8 +333,8 @@
if missing:
skip_decorator = unittest.skip('{0} not installed'.format(
', '.join(missing)))
- if (inspect.isclass(obj) and issubclass(obj, TestCaseBase) and
- 'nose' in sys.modules.keys()):
+ if (inspect.isclass(obj) and issubclass(obj, TestCaseBase)
+ and 'nose' in sys.modules.keys()):
# There is a known bug in nosetests which causes setUpClass()
# to be called even if the unittest class is skipped.
# Here, we decorate setUpClass() as a patch to skip it
@@ -592,8 +592,8 @@
'Set {}=1 to enable.'
.format(cls.__name__, env_var))
- if (not hasattr(site.family, 'test_codes') or
- site.code not in site.family.test_codes):
+ if (not hasattr(site.family, 'test_codes')
+ or site.code not in site.family.test_codes):
raise Exception(
'{} should only be run on test sites. '
"To run this test, add '{}' to the {} family "
@@ -735,8 +735,8 @@
for base in bases:
base_tests += [attr_name
for attr_name, attr in base.__dict__.items()
- if (attr_name.startswith('test') and
- callable(attr))]
+ if (attr_name.startswith('test')
+ and callable(attr))]
dct['abstract_class'] = not tests and not base_tests
@@ -792,8 +792,8 @@
if 'dry' in dct and dct['dry'] is True:
dct['net'] = False
- if (('sites' not in dct and 'site' not in dct) or
- ('site' in dct and not dct['site'])):
+ if (('sites' not in dct and 'site' not in dct)
+ or ('site' in dct and not dct['site'])):
# Prevent use of pywikibot.Site
bases = cls.add_base(bases, DisableSiteMixin)
@@ -850,8 +850,8 @@
dct['user'] = True
bases = cls.add_base(bases, SiteWriteMixin)
- if (('user' in dct and dct['user']) or
- ('sysop' in dct and dct['sysop'])):
+ if (('user' in dct and dct['user'])
+ or ('sysop' in dct and dct['sysop'])):
bases = cls.add_base(bases, RequireUserMixin)
for test in tests:
@@ -944,8 +944,8 @@
interface = DrySite
for data in cls.sites.values():
- if ('code' in data and data['code'] in ('test', 'mediawiki') and
- 'PYWIKIBOT_TEST_PROD_ONLY' in os.environ and not dry):
+ if ('code' in data and data['code'] in ('test', 'mediawiki')
+ and 'PYWIKIBOT_TEST_PROD_ONLY' in os.environ and not dry):
raise unittest.SkipTest(
'Site code "{}" and PYWIKIBOT_TEST_PROD_ONLY is set.'
.format(data['code']))
@@ -1011,8 +1011,8 @@
usernames = config.sysopnames if sysop else config.usernames
- return (code in usernames[family] or '*' in usernames[family] or
- code in usernames['*'] or '*' in usernames['*'])
+ return (code in usernames[family] or '*' in usernames[family]
+ or code in usernames['*'] or '*' in usernames['*'])
def __init__(self, *args, **kwargs):
"""Initializer."""
@@ -1316,8 +1316,8 @@
'{}: {!r} does not have data repository'
.format(cls.__name__, site))
- if (hasattr(cls, 'repo') and
- cls.repo != site.data_repository()):
+ if (hasattr(cls, 'repo')
+ and cls.repo != site.data_repository()):
raise Exception(
'{}: sites do not all have the same data repository'
.format(cls.__name__))
@@ -1585,8 +1585,8 @@
deprecation_messages = self.deprecation_messages
for deprecation_message in deprecation_messages:
match = self._generic_match.match(deprecation_message)
- if (match and bool(match.group(1)) == (msg is self.INSTEAD) or
- msg is None):
+ if (match and bool(match.group(1)) == (msg is self.INSTEAD)
+ or msg is None):
break
else:
self.fail('No generic deprecation message match found in '
@@ -1638,8 +1638,8 @@
def assertDeprecationFile(self, filename):
"""Assert that all deprecation warning are of one filename."""
for item in self.warning_log:
- if (self._ignore_unknown_warning_packages and
- 'pywikibot' not in item.filename):
+ if (self._ignore_unknown_warning_packages
+ and 'pywikibot' not in item.filename):
continue
if item.filename != filename:
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index 01e5dcb..f93a98c 100644
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -222,8 +222,8 @@
req = CachedRequest(expiry=1, site=self.mocksite,
parameters={'action': 'query', 'meta': 'siteinfo'})
- expect = ('MockSite()User(User:محمد الفلسطيني)' +
- "[('action', 'query'), ('meta', 'siteinfo')]")
+ expect = ('MockSite()User(User:محمد الفلسطيني)'
+ + "[('action', 'query'), ('meta', 'siteinfo')]")
self.assertEqual(repr(req._uniquedescriptionstr()), repr(expect))
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 1bca38e..6d4ef3e 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -66,15 +66,15 @@
def list_scripts(path, exclude=None):
"""Return list of scripts in given path."""
scripts = [name[0:-3] for name in os.listdir(path) # strip '.py'
- if name.endswith('.py') and
- not name.startswith('_') and # skip __init__.py and _*
- name != exclude]
+ if name.endswith('.py')
+ and not name.startswith('_') # skip __init__.py and _*
+ and name != exclude]
return scripts
-script_list = (['login'] +
- list_scripts(scripts_path, 'login.py') +
- list_scripts(archive_path))
+script_list = (['login']
+ + list_scripts(scripts_path, 'login.py')
+ + list_scripts(archive_path))
runnable_script_list = (
['login'] + sorted(set(script_list) - {'login'} - unrunnable_script_set))
@@ -184,24 +184,24 @@
'(set PYWIKIBOT_TEST_AUTORUN=1 to enable):\n {!r}'
.format(auto_run_script_list))
- tests = (['test__login'] +
- ['test_' + name
- for name in sorted(script_list)
- if name != 'login'
- and name not in unrunnable_script_set
- ])
+ tests = (['test__login']
+ + ['test_' + name
+ for name in sorted(script_list)
+ if name != 'login'
+ and name not in unrunnable_script_set
+ ])
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_set
- and name not in unrunnable_script_set
- and (enable_autorun_tests or name not in auto_run_script_list)
- ])
+ tests = (['test__login']
+ + ['test_' + name
+ for name in sorted(script_list)
+ if name != 'login'
+ and name not in failed_dep_script_set
+ and name not in unrunnable_script_set
+ and (enable_autorun_tests or name not in auto_run_script_list)
+ ])
test_list += ['tests.script_tests.TestScriptSimulate.' + name
for name in tests]
@@ -225,8 +225,8 @@
def __new__(cls, name, bases, dct):
"""Create the new class."""
def test_execution(script_name, args=[]):
- is_autorun = ('-help' not in args and
- script_name in auto_run_script_list)
+ is_autorun = ('-help' not in args
+ and script_name in auto_run_script_list)
def test_skip_script(self):
raise unittest.SkipTest(
--
To view, visit https://gerrit.wikimedia.org/r/474469
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6f487498539a2f204ef02b47f3417dc2ba50f721
Gerrit-Change-Number: 474469
Gerrit-PatchSet: 5
Gerrit-Owner: Nathan fraignt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: Framawiki <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits