Fixed E225 flake8 errors

missing whitespace around operator
This commit is contained in:
Andras Tim 2017-07-17 01:25:08 +02:00
parent 3fabc4d219
commit 2e8caefcab
20 changed files with 57 additions and 57 deletions

View File

@ -26,7 +26,7 @@ class Code(object):
self.firstlineno = rawcode.co_firstlineno - 1
self.name = rawcode.co_name
except AttributeError:
raise TypeError("not a code object: %r" %(rawcode,))
raise TypeError("not a code object: %r" % (rawcode,))
self.raw = rawcode
def __eq__(self, other):
@ -168,7 +168,7 @@ class TracebackEntry(object):
return self.lineno - self.frame.code.firstlineno
def __repr__(self):
return "<TracebackEntry %s:%d>" %(self.frame.code.path, self.lineno+1)
return "<TracebackEntry %s:%d>" % (self.frame.code.path, self.lineno+1)
@property
def statement(self):
@ -249,7 +249,7 @@ class TracebackEntry(object):
raise
except:
line = "???"
return " File %r:%d in %s\n %s\n" %(fn, self.lineno+1, name, line)
return " File %r:%d in %s\n %s\n" % (fn, self.lineno+1, name, line)
def name(self):
return self.frame.code.raw.co_name
@ -548,7 +548,7 @@ class FormattedExcinfo(object):
str_repr = self._saferepr(value)
#if len(str_repr) < 70 or not isinstance(value,
# (list, tuple, dict)):
lines.append("%-10s = %s" %(name, str_repr))
lines.append("%-10s = %s" % (name, str_repr))
#else:
# self._line("%-10s =\\" % (name,))
# # XXX
@ -575,7 +575,7 @@ class FormattedExcinfo(object):
s = self.get_source(source, line_index, excinfo, short=short)
lines.extend(s)
if short:
message = "in %s" %(entry.name)
message = "in %s" % (entry.name)
else:
message = excinfo and excinfo.typename or ""
path = self._makepath(entry.path)
@ -699,7 +699,7 @@ class TerminalRepr(object):
return io.getvalue().strip()
def __repr__(self):
return "<%s instance at %0x>" %(self.__class__, id(self))
return "<%s instance at %0x>" % (self.__class__, id(self))
class ExceptionRepr(TerminalRepr):
@ -850,7 +850,7 @@ class ReprFuncArgs(TerminalRepr):
if self.args:
linesofar = ""
for name, value in self.args:
ns = "%s = %s" %(name, value)
ns = "%s = %s" % (name, value)
if len(ns) + len(linesofar) + 2 > tw.fullwidth:
if linesofar:
tw.line(linesofar)

View File

@ -261,7 +261,7 @@ def _write_pyc(state, co, source_stat, pyc):
fp = open(pyc, "wb")
except IOError:
err = sys.exc_info()[1].errno
state.trace("error writing pyc file at %s: errno=%s" %(pyc, err))
state.trace("error writing pyc file at %s: errno=%s" % (pyc, err))
# we ignore any failure to write the cache file
# there are many reasons, permission-denied, __pycache__ being a
# file etc.

View File

@ -68,7 +68,7 @@ def getlocation(function, curdir):
lineno = py.builtin._getcode(function).co_firstlineno
if fn.relto(curdir):
fn = fn.relto(curdir)
return "%s:%d" %(fn, lineno+1)
return "%s:%d" % (fn, lineno+1)
def num_mock_patch_args(function):

View File

@ -60,7 +60,7 @@ def main(args=None, plugins=None):
config._ensure_unconfigure()
except UsageError as e:
for msg in e.args:
sys.stderr.write("ERROR: %s\n" %(msg,))
sys.stderr.write("ERROR: %s\n" % (msg,))
return 4
class cmdline: # compatibility namespace
@ -382,7 +382,7 @@ class PytestPluginManager(PluginManager):
if path and path.relto(dirpath) or path == dirpath:
assert mod not in mods
mods.append(mod)
self.trace("loaded conftestmodule %r" %(mod))
self.trace("loaded conftestmodule %r" % (mod))
self.consider_conftest(mod)
return mod
@ -446,7 +446,7 @@ class PytestPluginManager(PluginManager):
import pytest
if not hasattr(pytest, 'skip') or not isinstance(e, pytest.skip.Exception):
raise
self._warn("skipped plugin %r: %s" %((modname, e.msg)))
self._warn("skipped plugin %r: %s" % ((modname, e.msg)))
else:
mod = sys.modules[importspec]
self.register(mod, modname)
@ -549,7 +549,7 @@ class Parser:
a = option.attrs()
arggroup.add_argument(*n, **a)
# bash like autocompletion for dirs (appending '/')
optparser.add_argument(FILE_OR_DIR, nargs='*').completer=filescompleter
optparser.add_argument(FILE_OR_DIR, nargs='*').completer = filescompleter
return optparser
def parse_setoption(self, args, option, namespace=None):
@ -857,7 +857,7 @@ class CmdOptions(object):
def __init__(self, values=()):
self.__dict__.update(values)
def __repr__(self):
return "<CmdOptions %r>" %(self.__dict__,)
return "<CmdOptions %r>" % (self.__dict__,)
def copy(self):
return CmdOptions(self.__dict__)
@ -947,7 +947,7 @@ class Config(object):
excinfo=excinfo)
if not py.builtin.any(res):
for line in str(excrepr).split("\n"):
sys.stderr.write("INTERNALERROR> %s\n" %line)
sys.stderr.write("INTERNALERROR> %s\n" % line)
sys.stderr.flush()
def cwd_relative_nodeid(self, nodeid):
@ -1092,7 +1092,7 @@ class Config(object):
myver = pytest.__version__.split(".")
if myver < ver:
raise pytest.UsageError(
"%s:%d: requires pytest-%s, actual pytest-%s'" %(
"%s:%d: requires pytest-%s, actual pytest-%s'" % (
self.inicfg.config.path, self.inicfg.lineof('minversion'),
minver, pytest.__version__))
@ -1142,7 +1142,7 @@ class Config(object):
try:
description, type, default = self._parser._inidict[name]
except KeyError:
raise ValueError("unknown configuration value: %r" %(name,))
raise ValueError("unknown configuration value: %r" % (name,))
value = self._get_override_ini_value(name)
if value is None:
try:
@ -1219,7 +1219,7 @@ class Config(object):
return default
if skip:
import pytest
pytest.skip("no %r option found" %(name,))
pytest.skip("no %r option found" % (name,))
raise ValueError("no option named %r" % (name,))
def getvalue(self, name, path=None):

View File

@ -553,7 +553,7 @@ class FixtureRequest(FuncargnamesCompatAttr):
return node
def __repr__(self):
return "<FixtureRequest for %r>" %(self.node)
return "<FixtureRequest for %r>" % (self.node)
class SubRequest(FixtureRequest):
@ -649,7 +649,7 @@ class FixtureLookupError(LookupError):
if faclist and name not in available:
available.append(name)
msg = "fixture %r not found" % (self.argname,)
msg += "\n available fixtures: %s" %(", ".join(sorted(available)),)
msg += "\n available fixtures: %s" % (", ".join(sorted(available)),)
msg += "\n use 'pytest --fixtures [testpath]' for help on them."
return FixtureLookupErrorRepr(fspath, lineno, tblines, msg, self.argname)

View File

@ -69,7 +69,7 @@ def pytest_cmdline_parse():
path = os.path.abspath("pytestdebug.log")
debugfile = open(path, 'w')
debugfile.write("versions pytest-%s, py-%s, "
"python-%s\ncwd=%s\nargs=%s\n\n" %(
"python-%s\ncwd=%s\nargs=%s\n\n" % (
pytest.__version__, py.__version__,
".".join(map(str, sys.version_info)),
os.getcwd(), config._origargs))
@ -117,7 +117,7 @@ def showhelp(config):
if type is None:
type = "string"
spec = "%s (%s)" % (name, type)
line = " %-24s %s" %(spec, help)
line = " %-24s %s" % (spec, help)
tw.line(line[:tw.fullwidth])
tw.line()
@ -175,5 +175,5 @@ def pytest_report_header(config):
r = plugin.__file__
else:
r = repr(plugin)
lines.append(" %-20s: %s" %(name, r))
lines.append(" %-20s: %s" % (name, r))
return lines

View File

@ -307,8 +307,8 @@ class Node(object):
return cls
def __repr__(self):
return "<%s %r>" %(self.__class__.__name__,
getattr(self, 'name', None))
return "<%s %r>" % (self.__class__.__name__,
getattr(self, 'name', None))
def warn(self, code, message):
""" generate a warning with the given code and message for this
@ -429,7 +429,7 @@ class Node(object):
return excinfo.value.formatrepr()
tbfilter = True
if self.config.option.fulltrace:
style="long"
style = "long"
else:
tb = _pytest._code.Traceback([excinfo.traceback[-1]])
self._prunetraceback(excinfo)

View File

@ -97,4 +97,4 @@ def pytest_terminal_summary(terminalreporter):
s = tw.stringio.getvalue()
assert len(s)
pastebinurl = create_new_paste(s)
tr.write_line("%s --> %s" %(msg, pastebinurl))
tr.write_line("%s --> %s" % (msg, pastebinurl))

View File

@ -190,7 +190,7 @@ class ParsedCall:
def __repr__(self):
d = self.__dict__.copy()
del d['_name']
return "<ParsedCall %r(**%r)>" %(self._name, d)
return "<ParsedCall %r(**%r)>" % (self._name, d)
class HookRecorder:
@ -283,7 +283,7 @@ class HookRecorder:
"no test reports at all!" % (inamepart,))
if len(l) > 1:
raise ValueError(
"found 2 or more testreports matching %r: %s" %(inamepart, l))
"found 2 or more testreports matching %r: %s" % (inamepart, l))
return l[0]
def getfailures(self,
@ -838,7 +838,7 @@ class Testdir:
for item in items:
if item.name == funcname:
return item
assert 0, "%r item not found in module:\n%s\nitems: %s" %(
assert 0, "%r item not found in module:\n%s\nitems: %s" % (
funcname, source, items)
def getitems(self, source):

View File

@ -606,13 +606,13 @@ class Generator(FunctionMixin, PyCollector):
for i, x in enumerate(self.obj()):
name, call, args = self.getcallargs(x)
if not callable(call):
raise TypeError("%r yielded non callable test %r" %(self.obj, call,))
raise TypeError("%r yielded non callable test %r" % (self.obj, call,))
if name is None:
name = "[%d]" % i
else:
name = "['%s']" % name
if name in seen:
raise ValueError("%r generated tests with non-unique name %r" %(self, name))
raise ValueError("%r generated tests with non-unique name %r" % (self, name))
seen[name] = True
l.append(self.Function(name, self, args=args, callobj=call))
self.warn('C1', deprecated.YIELD_TESTS)
@ -671,7 +671,7 @@ class CallSpec2(object):
def _checkargnotcontained(self, arg):
if arg in self.params or arg in self.funcargs:
raise ValueError("duplicate %r" %(arg,))
raise ValueError("duplicate %r" % (arg,))
def getparam(self, name):
try:
@ -1072,12 +1072,12 @@ def _showfixtures_main(config, session):
if currentmodule != module:
if not module.startswith("_pytest."):
tw.line()
tw.sep("-", "fixtures defined from %s" %(module,))
tw.sep("-", "fixtures defined from %s" % (module,))
currentmodule = module
if verbose <= 0 and argname[0] == "_":
continue
if verbose > 0:
funcargspec = "%s -- %s" %(argname, bestrel,)
funcargspec = "%s -- %s" % (argname, bestrel,)
else:
funcargspec = argname
tw.line(funcargspec, green=True)
@ -1087,7 +1087,7 @@ def _showfixtures_main(config, session):
for line in doc.strip().split("\n"):
tw.line(" " + line.strip())
else:
tw.line(" %s: no docstring available" %(loc,),
tw.line(" %s: no docstring available" % (loc,),
red=True)

View File

@ -268,7 +268,7 @@ def pytest_runtest_makereport(item, call):
longrepr = item._repr_failure_py(excinfo,
style=item.config.option.tbstyle)
for rwhen, key, content in item._report_sections:
sections.append(("Captured %s %s" %(key, rwhen), content))
sections.append(("Captured %s %s" % (key, rwhen), content))
return TestReport(item.nodeid, item.location,
keywords, outcome, longrepr, when,
sections, duration)
@ -480,7 +480,7 @@ class OutcomeException(Exception):
if isinstance(val, bytes):
val = py._builtin._totext(val, errors='replace')
return val
return "<%s instance>" %(self.__class__.__name__,)
return "<%s instance>" % (self.__class__.__name__,)
__str__ = __repr__
class Skipped(OutcomeException):
@ -562,7 +562,7 @@ def importorskip(modname, minversion=None):
# Do not raise chained exception here(#1485)
should_skip = True
if should_skip:
raise Skipped("could not import %r" %(modname,), allow_module_level=True)
raise Skipped("could not import %r" % (modname,), allow_module_level=True)
mod = sys.modules[modname]
if minversion is None:
return mod
@ -575,6 +575,6 @@ def importorskip(modname, minversion=None):
"pkg_resources to parse version strings." % (modname,),
allow_module_level=True)
if verattr is None or pv(verattr) < pv(minversion):
raise Skipped("module %r has __version__ %r, required is: %r" %(
raise Skipped("module %r has __version__ %r, required is: %r" % (
modname, verattr, minversion), allow_module_level=True)
return mod

View File

@ -131,7 +131,7 @@ class TestGeneralUsage(object):
result = testdir.runpytest(p1, p2)
assert result.ret
result.stderr.fnmatch_lines([
"*ERROR: not found:*%s" %(p2.basename,)
"*ERROR: not found:*%s" % (p2.basename,)
])
def test_issue486_better_reporting_on_conftest_load_failure(self, testdir):

View File

@ -78,7 +78,7 @@ def test_source_putaround_simple():
x = 42
else:
x = 23""")
assert str(source)=="""\
assert str(source) == """\
try:
raise ValueError
except ValueError:
@ -291,7 +291,7 @@ class TestSourceParsingAndCompiling(object):
def check(comp, name):
co = comp(self.source, name)
if not name:
expected = "codegen %s:%d>" %(mypath, mylineno+2+2)
expected = "codegen %s:%d>" % (mypath, mylineno+2+2)
else:
expected = "codegen %r %s:%d>" % (name, mypath, mylineno+2+2)
fn = co.co_filename

View File

@ -2565,7 +2565,7 @@ class TestRequestScopeAccess(object):
assert request.config
def test_func():
pass
""" %(scope, ok.split(), error.split()))
""" % (scope, ok.split(), error.split()))
reprec = testdir.inline_run("-l")
reprec.assertoutcome(passed=1)
@ -2583,7 +2583,7 @@ class TestRequestScopeAccess(object):
assert request.config
def test_func(arg):
pass
""" %(scope, ok.split(), error.split()))
""" % (scope, ok.split(), error.split()))
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)

View File

@ -619,7 +619,7 @@ class TestTruncateExplanation(object):
assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG
assert "Full output truncated" in result[-1]
assert "43 lines hidden" in result[-1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG -1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG - 1]
assert last_line_before_trunc_msg.endswith("...")
def test_truncates_at_8_lines_when_first_8_lines_are_LT_max_chars(self):
@ -629,7 +629,7 @@ class TestTruncateExplanation(object):
assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG
assert "Full output truncated" in result[-1]
assert "93 lines hidden" in result[-1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG -1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG - 1]
assert last_line_before_trunc_msg.endswith("...")
def test_truncates_at_8_lines_when_first_8_lines_are_EQ_max_chars(self):
@ -639,7 +639,7 @@ class TestTruncateExplanation(object):
assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG
assert "Full output truncated" in result[-1]
assert "9 lines hidden" in result[-1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG -1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG - 1]
assert last_line_before_trunc_msg.endswith("...")
def test_truncates_at_4_lines_when_first_4_lines_are_GT_max_chars(self):
@ -649,7 +649,7 @@ class TestTruncateExplanation(object):
assert len(result) == 4 + self.LINES_IN_TRUNCATION_MSG
assert "Full output truncated" in result[-1]
assert "7 lines hidden" in result[-1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG -1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG - 1]
assert last_line_before_trunc_msg.endswith("...")
def test_truncates_at_1_line_when_first_line_is_GT_max_chars(self):
@ -659,7 +659,7 @@ class TestTruncateExplanation(object):
assert len(result) == 1 + self.LINES_IN_TRUNCATION_MSG
assert "Full output truncated" in result[-1]
assert "1000 lines hidden" in result[-1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG -1]
last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG - 1]
assert last_line_before_trunc_msg.endswith("...")
def test_full_output_truncated(self, monkeypatch, testdir):

View File

@ -347,10 +347,10 @@ class TestConftestVisibility(object):
def test_parsefactories_relative_node_ids(
self, testdir, chdir,testarg, expect_ntests_passed):
dirs = self._setup_tree(testdir)
print("pytest run in cwd: %s" %(
print("pytest run in cwd: %s" % (
dirs[chdir].relto(testdir.tmpdir)))
print("pytestarg : %s" %(testarg))
print("expected pass : %s" %(expect_ntests_passed))
print("pytestarg : %s" % (testarg))
print("expected pass : %s" % (expect_ntests_passed))
with dirs[chdir].as_cwd():
reprec = testdir.inline_run(testarg, "-q", "--traceconfig")
reprec.assertoutcome(passed=expect_ntests_passed)

View File

@ -273,7 +273,7 @@ def test_argcomplete(testdir, monkeypatch):
script = str(testdir.tmpdir.join("test_argcomplete"))
pytest_bin = sys.argv[0]
if "pytest" not in os.path.basename(pytest_bin):
pytest.skip("need to be run with pytest executable, not %s" %(pytest_bin,))
pytest.skip("need to be run with pytest executable, not %s" % (pytest_bin,))
with open(str(script), 'w') as fp:
# redirect output from argcomplete to stdin and stderr is not trivial

View File

@ -319,7 +319,7 @@ class TestPDB(object):
pytest.set_trace()
x = 5
""")
child = testdir.spawn("%s %s" %(sys.executable, p1))
child = testdir.spawn("%s %s" % (sys.executable, p1))
child.expect("x = 5")
child.sendeof()
self.flush(child)

View File

@ -80,7 +80,7 @@ class TestEvaluator(object):
%s
def test_func():
pass
""" % (lines[i], lines[(i+1) %2]))
""" % (lines[i], lines[(i+1) % 2]))
ev = MarkEvaluator(item, 'skipif')
assert ev
assert ev.istrue()

View File

@ -196,6 +196,6 @@ filterwarnings =
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
[flake8]
ignore = E225,E226,E231,E241,E251,E261,E262,E265,E271,E272,E293,E301,E302,E303,E401,E402,E501,E701,E702,E704,E712,E731
ignore = E226,E231,E241,E251,E261,E262,E265,E271,E272,E293,E301,E302,E303,E401,E402,E501,E701,E702,E704,E712,E731
max-line-length = 120
exclude = _pytest/vendored_packages/pluggy.py