Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions _pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def __str__(self):
line = str(self.statement).lstrip()
except KeyboardInterrupt:
raise
except:
except: # noqa
line = "???"
return " File %r:%d in %s\n %s\n" % (fn, self.lineno + 1, name, line)

Expand Down Expand Up @@ -338,16 +338,16 @@ def recursionindex(self):
# XXX needs a test
key = entry.frame.code.path, id(entry.frame.code.raw), entry.lineno
# print "checking for recursion at", key
l = cache.setdefault(key, [])
if l:
values = cache.setdefault(key, [])
if values:
f = entry.frame
loc = f.f_locals
for otherloc in l:
for otherloc in values:
if f.is_true(f.eval(co_equal,
__recursioncache_locals_1=loc,
__recursioncache_locals_2=otherloc)):
return i
l.append(entry.frame.f_locals)
values.append(entry.frame.f_locals)
return None


Expand Down Expand Up @@ -478,12 +478,12 @@ def _getindent(self, source):
s = str(source.getstatement(len(source) - 1))
except KeyboardInterrupt:
raise
except:
except: # noqa
try:
s = str(source[-1])
except KeyboardInterrupt:
raise
except:
except: # noqa
return 0
return 4 + (len(s) - len(s.lstrip()))

Expand Down
18 changes: 9 additions & 9 deletions _pytest/_code/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def findsource(obj):
sourcelines, lineno = py.std.inspect.findsource(obj)
except py.builtin._sysex:
raise
except:
except: # noqa
return None, -1
source = Source()
source.lines = [line.rstrip() for line in sourcelines]
Expand Down Expand Up @@ -319,22 +319,22 @@ def get_statement_startend2(lineno, node):
import ast
# flatten all statements and except handlers into one lineno-list
# AST's line numbers start indexing at 1
l = []
values = []
for x in ast.walk(node):
if isinstance(x, _ast.stmt) or isinstance(x, _ast.ExceptHandler):
l.append(x.lineno - 1)
values.append(x.lineno - 1)
for name in "finalbody", "orelse":
val = getattr(x, name, None)
if val:
# treat the finally/orelse part as its own statement
l.append(val[0].lineno - 1 - 1)
l.sort()
insert_index = bisect_right(l, lineno)
start = l[insert_index - 1]
if insert_index >= len(l):
values.append(val[0].lineno - 1 - 1)
values.sort()
insert_index = bisect_right(values, lineno)
start = values[insert_index - 1]
if insert_index >= len(values):
end = None
else:
end = l[insert_index]
end = values[insert_index]
return start, end


Expand Down
2 changes: 1 addition & 1 deletion _pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def load_module(self, name):
mod.__cached__ = pyc
mod.__loader__ = self
py.builtin.exec_(co, mod.__dict__)
except:
except: # noqa
if name in sys.modules:
del sys.modules[name]
raise
Expand Down
8 changes: 4 additions & 4 deletions _pytest/assertion/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def _split_explanation(explanation):
"""
raw_lines = (explanation or u('')).split('\n')
lines = [raw_lines[0]]
for l in raw_lines[1:]:
if l and l[0] in ['{', '}', '~', '>']:
lines.append(l)
for values in raw_lines[1:]:
if values and values[0] in ['{', '}', '~', '>']:
lines.append(values)
else:
lines[-1] += '\\n' + l
lines[-1] += '\\n' + values
return lines


Expand Down
12 changes: 6 additions & 6 deletions _pytest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,10 +1170,10 @@ def _getini(self, name):
return []
if type == "pathlist":
dp = py.path.local(self.inicfg.config.path).dirpath()
l = []
values = []
for relpath in shlex.split(value):
l.append(dp.join(relpath, abs=True))
return l
values.append(dp.join(relpath, abs=True))
return values
elif type == "args":
return shlex.split(value)
elif type == "linelist":
Expand All @@ -1190,13 +1190,13 @@ def _getconftest_pathlist(self, name, path):
except KeyError:
return None
modpath = py.path.local(mod.__file__).dirpath()
l = []
values = []
for relroot in relroots:
if not isinstance(relroot, py.path.local):
relroot = relroot.replace("/", py.path.local.sep)
relroot = modpath.join(relroot, abs=True)
l.append(relroot)
return l
values.append(relroot)
return values

def _get_override_ini_value(self, name):
value = None
Expand Down
10 changes: 5 additions & 5 deletions _pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,13 @@ class PseudoFixtureDef:

def _get_fixturestack(self):
current = self
l = []
values = []
while 1:
fixturedef = getattr(current, "_fixturedef", None)
if fixturedef is None:
l.reverse()
return l
l.append(fixturedef)
values.reverse()
return values
values.append(fixturedef)
current = current._parent_request

def _getfixturevalue(self, fixturedef):
Expand Down Expand Up @@ -749,7 +749,7 @@ def finish(self):
try:
func = self._finalizer.pop()
func()
except:
except: # noqa
exceptions.append(sys.exc_info())
if exceptions:
e = exceptions[0]
Expand Down
4 changes: 2 additions & 2 deletions _pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def wrap_session(config, doit):
excinfo.typename, excinfo.value.msg))
config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
session.exitstatus = EXIT_INTERRUPTED
except:
except: # noqa
excinfo = _pytest._code.ExceptionInfo()
config.notify_exception(excinfo, config.option)
session.exitstatus = EXIT_INTERNALERROR
Expand Down Expand Up @@ -375,7 +375,7 @@ def _memoizedcall(self, attrname, function):
res = function()
except py.builtin._sysex:
raise
except:
except: # noqa
failure = sys.exc_info()
setattr(self, exattrname, failure)
raise
Expand Down
4 changes: 2 additions & 2 deletions _pytest/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ def _check(self, name):
return
except AttributeError:
pass
self._markers = l = set()
self._markers = values = set()
for line in self._config.getini("markers"):
marker, _ = line.split(":", 1)
marker = marker.rstrip()
x = marker.split("(", 1)[0]
l.add(x)
values.add(x)
if name not in self._markers:
raise AttributeError("%r not a registered marker" % (name,))

Expand Down
28 changes: 14 additions & 14 deletions _pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ def gethookrecorder(self, hook):
return hookrecorder


def get_public_names(l):
"""Only return names from iterator l without a leading underscore."""
return [x for x in l if x[0] != "_"]
def get_public_names(values):
"""Only return names from iterator values without a leading underscore."""
return [x for x in values if x[0] != "_"]


class ParsedCall:
Expand Down Expand Up @@ -258,9 +258,9 @@ def popcall(self, name):
pytest.fail("\n".join(lines))

def getcall(self, name):
l = self.getcalls(name)
assert len(l) == 1, (name, l)
return l[0]
values = self.getcalls(name)
assert len(values) == 1, (name, values)
return values[0]

# functionality for test reports

Expand All @@ -271,7 +271,7 @@ def getreports(self,
def matchreport(self, inamepart="",
names="pytest_runtest_logreport pytest_collectreport", when=None):
""" return a testreport whose dotted import path matches """
l = []
values = []
for rep in self.getreports(names=names):
try:
if not when and rep.when != "call" and rep.passed:
Expand All @@ -282,14 +282,14 @@ def matchreport(self, inamepart="",
if when and getattr(rep, 'when', None) != when:
continue
if not inamepart or inamepart in rep.nodeid.split("::"):
l.append(rep)
if not l:
values.append(rep)
if not values:
raise ValueError("could not find test report matching %r: "
"no test reports at all!" % (inamepart,))
if len(l) > 1:
if len(values) > 1:
raise ValueError(
"found 2 or more testreports matching %r: %s" % (inamepart, l))
return l[0]
"found 2 or more testreports matching %r: %s" % (inamepart, values))
return values[0]

def getfailures(self,
names='pytest_runtest_logreport pytest_collectreport'):
Expand Down Expand Up @@ -673,8 +673,8 @@ def inline_runsource(self, source, *cmdlineargs):

"""
p = self.makepyfile(source)
l = list(cmdlineargs) + [p]
return self.inline_run(*l)
values = list(cmdlineargs) + [p]
return self.inline_run(*values)

def inline_genitems(self, *args):
"""Run ``pytest.main(['--collectonly'])`` in-process.
Expand Down
14 changes: 7 additions & 7 deletions _pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def collect(self):
for basecls in inspect.getmro(self.obj.__class__):
dicts.append(basecls.__dict__)
seen = {}
l = []
values = []
for dic in dicts:
for name, obj in list(dic.items()):
if name in seen:
Expand All @@ -332,9 +332,9 @@ def collect(self):
continue
if not isinstance(res, list):
res = [res]
l.extend(res)
l.sort(key=lambda item: item.reportinfo()[:2])
return l
values.extend(res)
values.sort(key=lambda item: item.reportinfo()[:2])
return values

def makeitem(self, name, obj):
# assert self.ihook.fspath == self.fspath, self
Expand Down Expand Up @@ -592,7 +592,7 @@ def collect(self):
self.session._setupstate.prepare(self)
# see FunctionMixin.setup and test_setupstate_is_preserved_134
self._preservedparent = self.parent.obj
l = []
values = []
seen = {}
for i, x in enumerate(self.obj()):
name, call, args = self.getcallargs(x)
Expand All @@ -605,9 +605,9 @@ def collect(self):
if name in seen:
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))
values.append(self.Function(name, self, args=args, callobj=call))
self.warn('C1', deprecated.YIELD_TESTS)
return l
return values

def getcallargs(self, obj):
if not isinstance(obj, (tuple, list)):
Expand Down
2 changes: 1 addition & 1 deletion _pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __eq__(self, actual):

try:
actual = np.asarray(actual)
except:
except: # noqa
raise TypeError("cannot compare '{0}' to numpy.ndarray".format(actual))

if actual.shape != self.expected.shape:
Expand Down
2 changes: 1 addition & 1 deletion _pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __init__(self, func, when):
except KeyboardInterrupt:
self.stop = time()
raise
except:
except: # noqa
self.excinfo = ExceptionInfo()
self.stop = time()

Expand Down
6 changes: 3 additions & 3 deletions _pytest/skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ def folded_skips(skipped):
key = event.longrepr
assert len(key) == 3, (event, key)
d.setdefault(key, []).append(event)
l = []
values = []
for key, events in d.items():
l.append((len(events),) + key)
return l
values.append((len(events),) + key)
return values


def show_skipped(terminalreporter, lines):
Expand Down
24 changes: 12 additions & 12 deletions _pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ def mkrel(nodeid):
line = self.config.cwd_relative_nodeid(nodeid)
if domain and line.endswith(domain):
line = line[:-len(domain)]
l = domain.split("[")
l[0] = l[0].replace('.', '::') # don't replace '.' in params
line += "[".join(l)
values = domain.split("[")
values[0] = values[0].replace('.', '::') # don't replace '.' in params
line += "[".join(values)
return line
# collect_fspath comes from testid which has a "/"-normalized path

Expand Down Expand Up @@ -479,11 +479,11 @@ def _getcrashline(self, rep):
# summaries for sessionfinish
#
def getreports(self, name):
l = []
values = []
for x in self.stats.get(name, []):
if not hasattr(x, '_pdbshown'):
l.append(x)
return l
values.append(x)
return values

def summary_warnings(self):
if self.hasopt("w"):
Expand Down Expand Up @@ -594,8 +594,8 @@ def repr_pythonversion(v=None):
return str(v)


def flatten(l):
for x in l:
def flatten(values):
for x in values:
if isinstance(x, (list, tuple)):
for y in flatten(x):
yield y
Expand Down Expand Up @@ -636,7 +636,7 @@ def build_summary_stats_line(stats):


def _plugin_nameversions(plugininfo):
l = []
values = []
for plugin, dist in plugininfo:
# gets us name and version!
name = '{dist.project_name}-{dist.version}'.format(dist=dist)
Expand All @@ -645,6 +645,6 @@ def _plugin_nameversions(plugininfo):
name = name[7:]
# we decided to print python package names
# they can have more than one plugin
if name not in l:
l.append(name)
return l
if name not in values:
values.append(name)
return values
Loading