Skip to content

Commit d1af369

Browse files
Merge pull request #2913 from nicoddemus/merge-master-into-features
Merge master into features
2 parents 99496d9 + 983a09a commit d1af369

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+493
-481
lines changed

_pytest/_code/code.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def __str__(self):
248248
line = str(self.statement).lstrip()
249249
except KeyboardInterrupt:
250250
raise
251-
except:
251+
except: # noqa
252252
line = "???"
253253
return " File %r:%d in %s\n %s\n" % (fn, self.lineno + 1, name, line)
254254

@@ -336,16 +336,16 @@ def recursionindex(self):
336336
# XXX needs a test
337337
key = entry.frame.code.path, id(entry.frame.code.raw), entry.lineno
338338
# print "checking for recursion at", key
339-
l = cache.setdefault(key, [])
340-
if l:
339+
values = cache.setdefault(key, [])
340+
if values:
341341
f = entry.frame
342342
loc = f.f_locals
343-
for otherloc in l:
343+
for otherloc in values:
344344
if f.is_true(f.eval(co_equal,
345345
__recursioncache_locals_1=loc,
346346
__recursioncache_locals_2=otherloc)):
347347
return i
348-
l.append(entry.frame.f_locals)
348+
values.append(entry.frame.f_locals)
349349
return None
350350

351351

@@ -476,12 +476,12 @@ def _getindent(self, source):
476476
s = str(source.getstatement(len(source) - 1))
477477
except KeyboardInterrupt:
478478
raise
479-
except:
479+
except: # noqa
480480
try:
481481
s = str(source[-1])
482482
except KeyboardInterrupt:
483483
raise
484-
except:
484+
except: # noqa
485485
return 0
486486
return 4 + (len(s) - len(s.lstrip()))
487487

_pytest/_code/source.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def findsource(obj):
255255
sourcelines, lineno = py.std.inspect.findsource(obj)
256256
except py.builtin._sysex:
257257
raise
258-
except:
258+
except: # noqa
259259
return None, -1
260260
source = Source()
261261
source.lines = [line.rstrip() for line in sourcelines]
@@ -320,22 +320,22 @@ def get_statement_startend2(lineno, node):
320320
import ast
321321
# flatten all statements and except handlers into one lineno-list
322322
# AST's line numbers start indexing at 1
323-
l = []
323+
values = []
324324
for x in ast.walk(node):
325325
if isinstance(x, _ast.stmt) or isinstance(x, _ast.ExceptHandler):
326-
l.append(x.lineno - 1)
326+
values.append(x.lineno - 1)
327327
for name in "finalbody", "orelse":
328328
val = getattr(x, name, None)
329329
if val:
330330
# treat the finally/orelse part as its own statement
331-
l.append(val[0].lineno - 1 - 1)
332-
l.sort()
333-
insert_index = bisect_right(l, lineno)
334-
start = l[insert_index - 1]
335-
if insert_index >= len(l):
331+
values.append(val[0].lineno - 1 - 1)
332+
values.sort()
333+
insert_index = bisect_right(values, lineno)
334+
start = values[insert_index - 1]
335+
if insert_index >= len(values):
336336
end = None
337337
else:
338-
end = l[insert_index]
338+
end = values[insert_index]
339339
return start, end
340340

341341

_pytest/assertion/rewrite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def load_module(self, name):
210210
mod.__cached__ = pyc
211211
mod.__loader__ = self
212212
py.builtin.exec_(co, mod.__dict__)
213-
except:
213+
except: # noqa
214214
if name in sys.modules:
215215
del sys.modules[name]
216216
raise

_pytest/assertion/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ def _split_explanation(explanation):
5454
"""
5555
raw_lines = (explanation or u('')).split('\n')
5656
lines = [raw_lines[0]]
57-
for l in raw_lines[1:]:
58-
if l and l[0] in ['{', '}', '~', '>']:
59-
lines.append(l)
57+
for values in raw_lines[1:]:
58+
if values and values[0] in ['{', '}', '~', '>']:
59+
lines.append(values)
6060
else:
61-
lines[-1] += '\\n' + l
61+
lines[-1] += '\\n' + values
6262
return lines
6363

6464

_pytest/config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,10 @@ def _getini(self, name):
11521152
return []
11531153
if type == "pathlist":
11541154
dp = py.path.local(self.inicfg.config.path).dirpath()
1155-
l = []
1155+
values = []
11561156
for relpath in shlex.split(value):
1157-
l.append(dp.join(relpath, abs=True))
1158-
return l
1157+
values.append(dp.join(relpath, abs=True))
1158+
return values
11591159
elif type == "args":
11601160
return shlex.split(value)
11611161
elif type == "linelist":
@@ -1172,13 +1172,13 @@ def _getconftest_pathlist(self, name, path):
11721172
except KeyError:
11731173
return None
11741174
modpath = py.path.local(mod.__file__).dirpath()
1175-
l = []
1175+
values = []
11761176
for relroot in relroots:
11771177
if not isinstance(relroot, py.path.local):
11781178
relroot = relroot.replace("/", py.path.local.sep)
11791179
relroot = modpath.join(relroot, abs=True)
1180-
l.append(relroot)
1181-
return l
1180+
values.append(relroot)
1181+
return values
11821182

11831183
def _get_override_ini_value(self, name):
11841184
value = None

_pytest/fixtures.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,13 @@ class PseudoFixtureDef:
458458

459459
def _get_fixturestack(self):
460460
current = self
461-
l = []
461+
values = []
462462
while 1:
463463
fixturedef = getattr(current, "_fixturedef", None)
464464
if fixturedef is None:
465-
l.reverse()
466-
return l
467-
l.append(fixturedef)
465+
values.reverse()
466+
return values
467+
values.append(fixturedef)
468468
current = current._parent_request
469469

470470
def _getfixturevalue(self, fixturedef):
@@ -746,7 +746,7 @@ def finish(self):
746746
try:
747747
func = self._finalizer.pop()
748748
func()
749-
except:
749+
except: # noqa
750750
exceptions.append(sys.exc_info())
751751
if exceptions:
752752
e = exceptions[0]

_pytest/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def wrap_session(config, doit):
112112
excinfo.typename, excinfo.value.msg))
113113
config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
114114
session.exitstatus = EXIT_INTERRUPTED
115-
except:
115+
except: # noqa
116116
excinfo = _pytest._code.ExceptionInfo()
117117
config.notify_exception(excinfo, config.option)
118118
session.exitstatus = EXIT_INTERNALERROR

_pytest/mark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ def _check(self, name):
296296
return
297297
except AttributeError:
298298
pass
299-
self._markers = l = set()
299+
self._markers = values = set()
300300
for line in self._config.getini("markers"):
301301
marker, _ = line.split(":", 1)
302302
marker = marker.rstrip()
303303
x = marker.split("(", 1)[0]
304-
l.add(x)
304+
values.add(x)
305305
if name not in self._markers:
306306
raise AttributeError("%r not a registered marker" % (name,))
307307

_pytest/pytester.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ def gethookrecorder(self, hook):
174174
return hookrecorder
175175

176176

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

181181

182182
class ParsedCall:
@@ -250,9 +250,9 @@ def popcall(self, name):
250250
pytest.fail("\n".join(lines))
251251

252252
def getcall(self, name):
253-
l = self.getcalls(name)
254-
assert len(l) == 1, (name, l)
255-
return l[0]
253+
values = self.getcalls(name)
254+
assert len(values) == 1, (name, values)
255+
return values[0]
256256

257257
# functionality for test reports
258258

@@ -263,7 +263,7 @@ def getreports(self,
263263
def matchreport(self, inamepart="",
264264
names="pytest_runtest_logreport pytest_collectreport", when=None):
265265
""" return a testreport whose dotted import path matches """
266-
l = []
266+
values = []
267267
for rep in self.getreports(names=names):
268268
try:
269269
if not when and rep.when != "call" and rep.passed:
@@ -274,14 +274,14 @@ def matchreport(self, inamepart="",
274274
if when and getattr(rep, 'when', None) != when:
275275
continue
276276
if not inamepart or inamepart in rep.nodeid.split("::"):
277-
l.append(rep)
278-
if not l:
277+
values.append(rep)
278+
if not values:
279279
raise ValueError("could not find test report matching %r: "
280280
"no test reports at all!" % (inamepart,))
281-
if len(l) > 1:
281+
if len(values) > 1:
282282
raise ValueError(
283-
"found 2 or more testreports matching %r: %s" % (inamepart, l))
284-
return l[0]
283+
"found 2 or more testreports matching %r: %s" % (inamepart, values))
284+
return values[0]
285285

286286
def getfailures(self,
287287
names='pytest_runtest_logreport pytest_collectreport'):
@@ -652,8 +652,8 @@ def inline_runsource(self, source, *cmdlineargs):
652652
653653
"""
654654
p = self.makepyfile(source)
655-
l = list(cmdlineargs) + [p]
656-
return self.inline_run(*l)
655+
values = list(cmdlineargs) + [p]
656+
return self.inline_run(*values)
657657

658658
def inline_genitems(self, *args):
659659
"""Run ``pytest.main(['--collectonly'])`` in-process.

_pytest/python.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def collect(self):
325325
for basecls in inspect.getmro(self.obj.__class__):
326326
dicts.append(basecls.__dict__)
327327
seen = {}
328-
l = []
328+
values = []
329329
for dic in dicts:
330330
for name, obj in list(dic.items()):
331331
if name in seen:
@@ -336,9 +336,9 @@ def collect(self):
336336
continue
337337
if not isinstance(res, list):
338338
res = [res]
339-
l.extend(res)
340-
l.sort(key=lambda item: item.reportinfo()[:2])
341-
return l
339+
values.extend(res)
340+
values.sort(key=lambda item: item.reportinfo()[:2])
341+
return values
342342

343343
def makeitem(self, name, obj):
344344
warnings.warn(deprecated.COLLECTOR_MAKEITEM, stacklevel=2)
@@ -600,7 +600,7 @@ def collect(self):
600600
self.session._setupstate.prepare(self)
601601
# see FunctionMixin.setup and test_setupstate_is_preserved_134
602602
self._preservedparent = self.parent.obj
603-
l = []
603+
values = []
604604
seen = {}
605605
for i, x in enumerate(self.obj()):
606606
name, call, args = self.getcallargs(x)
@@ -613,9 +613,9 @@ def collect(self):
613613
if name in seen:
614614
raise ValueError("%r generated tests with non-unique name %r" % (self, name))
615615
seen[name] = True
616-
l.append(self.Function(name, self, args=args, callobj=call))
616+
values.append(self.Function(name, self, args=args, callobj=call))
617617
self.warn('C1', deprecated.YIELD_TESTS)
618-
return l
618+
return values
619619

620620
def getcallargs(self, obj):
621621
if not isinstance(obj, (tuple, list)):

_pytest/python_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __eq__(self, actual):
8585

8686
try:
8787
actual = np.asarray(actual)
88-
except:
88+
except: # noqa
8989
raise TypeError("cannot compare '{0}' to numpy.ndarray".format(actual))
9090

9191
if actual.shape != self.expected.shape:

_pytest/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def __init__(self, func, when):
197197
except KeyboardInterrupt:
198198
self.stop = time()
199199
raise
200-
except:
200+
except: # noqa
201201
self.excinfo = ExceptionInfo()
202202
self.stop = time()
203203

_pytest/skipping.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,10 @@ def folded_skips(skipped):
366366
if when == 'setup' and 'skip' in keywords and 'pytestmark' not in keywords:
367367
key = (key[0], None, key[2], )
368368
d.setdefault(key, []).append(event)
369-
l = []
369+
values = []
370370
for key, events in d.items():
371-
l.append((len(events),) + key)
372-
return l
371+
values.append((len(events),) + key)
372+
return values
373373

374374

375375
def show_skipped(terminalreporter, lines):

_pytest/terminal.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ def mkrel(nodeid):
459459
line = self.config.cwd_relative_nodeid(nodeid)
460460
if domain and line.endswith(domain):
461461
line = line[:-len(domain)]
462-
l = domain.split("[")
463-
l[0] = l[0].replace('.', '::') # don't replace '.' in params
464-
line += "[".join(l)
462+
values = domain.split("[")
463+
values[0] = values[0].replace('.', '::') # don't replace '.' in params
464+
line += "[".join(values)
465465
return line
466466
# collect_fspath comes from testid which has a "/"-normalized path
467467

@@ -493,11 +493,11 @@ def _getcrashline(self, rep):
493493
# summaries for sessionfinish
494494
#
495495
def getreports(self, name):
496-
l = []
496+
values = []
497497
for x in self.stats.get(name, []):
498498
if not hasattr(x, '_pdbshown'):
499-
l.append(x)
500-
return l
499+
values.append(x)
500+
return values
501501

502502
def summary_warnings(self):
503503
if self.hasopt("w"):
@@ -608,8 +608,8 @@ def repr_pythonversion(v=None):
608608
return str(v)
609609

610610

611-
def flatten(l):
612-
for x in l:
611+
def flatten(values):
612+
for x in values:
613613
if isinstance(x, (list, tuple)):
614614
for y in flatten(x):
615615
yield y
@@ -650,7 +650,7 @@ def build_summary_stats_line(stats):
650650

651651

652652
def _plugin_nameversions(plugininfo):
653-
l = []
653+
values = []
654654
for plugin, dist in plugininfo:
655655
# gets us name and version!
656656
name = '{dist.project_name}-{dist.version}'.format(dist=dist)
@@ -659,6 +659,6 @@ def _plugin_nameversions(plugininfo):
659659
name = name[7:]
660660
# we decided to print python package names
661661
# they can have more than one plugin
662-
if name not in l:
663-
l.append(name)
664-
return l
662+
if name not in values:
663+
values.append(name)
664+
return values

0 commit comments

Comments
 (0)