Skip to content

Commit

Permalink
Merge pull request #2913 from nicoddemus/merge-master-into-features
Browse files Browse the repository at this point in the history
Merge master into features
  • Loading branch information
RonnyPfannschmidt authored Nov 11, 2017
2 parents 99496d9 + 983a09a commit d1af369
Show file tree
Hide file tree
Showing 43 changed files with 493 additions and 481 deletions.
14 changes: 7 additions & 7 deletions _pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,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 @@ -336,16 +336,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 @@ -476,12 +476,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 @@ -255,7 +255,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 @@ -320,22 +320,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 @@ -54,11 +54,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 @@ -1152,10 +1152,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 @@ -1172,13 +1172,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 @@ -458,13 +458,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 @@ -746,7 +746,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
2 changes: 1 addition & 1 deletion _pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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
4 changes: 2 additions & 2 deletions _pytest/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,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 @@ -174,9 +174,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 @@ -250,9 +250,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 @@ -263,7 +263,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 @@ -274,14 +274,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 @@ -652,8 +652,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 @@ -325,7 +325,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 @@ -336,9 +336,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):
warnings.warn(deprecated.COLLECTOR_MAKEITEM, stacklevel=2)
Expand Down Expand Up @@ -600,7 +600,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 @@ -613,9 +613,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 @@ -85,7 +85,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 @@ -366,10 +366,10 @@ def folded_skips(skipped):
if when == 'setup' and 'skip' in keywords and 'pytestmark' not in keywords:
key = (key[0], None, key[2], )
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 @@ -459,9 +459,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 @@ -493,11 +493,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 @@ -608,8 +608,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 @@ -650,7 +650,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 @@ -659,6 +659,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

0 comments on commit d1af369

Please sign in to comment.