diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py index c964d2beb..797e1d293 100644 --- a/_pytest/_code/code.py +++ b/_pytest/_code/code.py @@ -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 "" %(self.frame.code.path, self.lineno+1) + return "" % (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) diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py index 95cc217d4..2ffa3c03e 100644 --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -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. diff --git a/_pytest/compat.py b/_pytest/compat.py index 38c0f1fac..22cba8450 100644 --- a/_pytest/compat.py +++ b/_pytest/compat.py @@ -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): diff --git a/_pytest/config.py b/_pytest/config.py index bfc3baa3f..a96e6a015 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -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 "" %(self.__dict__,) + return "" % (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): diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index bc9a4832e..aee55c8fa 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -553,7 +553,7 @@ class FixtureRequest(FuncargnamesCompatAttr): return node def __repr__(self): - return "" %(self.node) + return "" % (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) diff --git a/_pytest/helpconfig.py b/_pytest/helpconfig.py index 05d983803..72484fda5 100644 --- a/_pytest/helpconfig.py +++ b/_pytest/helpconfig.py @@ -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 diff --git a/_pytest/main.py b/_pytest/main.py index 712965a63..3e9c10b59 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -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) diff --git a/_pytest/pastebin.py b/_pytest/pastebin.py index 54590b48c..9d689819f 100644 --- a/_pytest/pastebin.py +++ b/_pytest/pastebin.py @@ -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)) diff --git a/_pytest/pytester.py b/_pytest/pytester.py index 4fc90e98c..223bdd79b 100644 --- a/_pytest/pytester.py +++ b/_pytest/pytester.py @@ -190,7 +190,7 @@ class ParsedCall: def __repr__(self): d = self.__dict__.copy() del d['_name'] - return "" %(self._name, d) + return "" % (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): diff --git a/_pytest/python.py b/_pytest/python.py index 8dec157c5..cb42c3fe2 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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) diff --git a/_pytest/runner.py b/_pytest/runner.py index 6e3ad0346..d029394ca 100644 --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -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 diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 3b3023f6c..1b1609600 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -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): diff --git a/testing/code/test_source.py b/testing/code/test_source.py index 6a9b458ec..dc48b29c3 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -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 diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 9985ee08d..751be095b 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -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) diff --git a/testing/test_assertion.py b/testing/test_assertion.py index a74496a65..e17e74183 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -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): diff --git a/testing/test_conftest.py b/testing/test_conftest.py index ed01c5410..3b01cc3cd 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -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) diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index f30770f35..6fc46ef24 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -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 diff --git a/testing/test_pdb.py b/testing/test_pdb.py index ec5862082..5429dd5d4 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -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) diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 94423da3b..afd5df16f 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -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() diff --git a/tox.ini b/tox.ini index 490c273f0..fd0cc814d 100644 --- a/tox.ini +++ b/tox.ini @@ -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