Skip to content

Merge master into features #2913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e23af00
Introduce a dedicated section about conftest.py
bilderbuchi Oct 23, 2017
52aadcd
Strip whitespace from markers in INI config
Perlence Oct 24, 2017
bdab29f
Merge pull request #2867 from Perlence/ini-markers-whitespace
nicoddemus Oct 24, 2017
0b540f9
Merge pull request #2864 from bilderbuchi/fix-1505
nicoddemus Oct 24, 2017
3427d27
Try to get docstring from module node
Perlence Oct 25, 2017
fd7bfa3
Put imports on the last line unless there are other exprs
Perlence Oct 25, 2017
383239c
doc: Include collector config in the skip doc
stephenfin Oct 26, 2017
27bb2ec
Add comment about why we remove docstrings on test_assertrewrite
nicoddemus Oct 26, 2017
734c435
Merge pull request #2870 from Perlence/rewrite-python-37-docstring
nicoddemus Oct 26, 2017
111d640
Merge pull request #2873 from stephenfin/doc/skipping-entire-files
nicoddemus Oct 26, 2017
c3ba922
Change directory for py27 xdist-related envs
nicoddemus Oct 26, 2017
27cea34
Remove trailing whitespace
nicoddemus Oct 26, 2017
af5e923
Document pytest.param
dawranliou Oct 28, 2017
2f993af
Fix context output handling for doctests
twmr Oct 29, 2017
d00e2da
Merge pull request #2881 from dawran6/2658
RonnyPfannschmidt Oct 30, 2017
26019b3
Merge pull request #2882 from thisch/doctest_lineno
RonnyPfannschmidt Oct 30, 2017
cd747c4
Merge pull request #2874 from nicoddemus/fix-py27-xdist-envs-2843
RonnyPfannschmidt Oct 30, 2017
802585c
Clarify language of proposal for parametrized fixtures
fmichea Nov 3, 2017
22e9b00
Add fragment per PR's guidelines.
fmichea Nov 3, 2017
2e2f721
Merge pull request #2893 from fmichea/patch-1
RonnyPfannschmidt Nov 4, 2017
03829fd
Fix linting E741: ambiguous variable name
nicoddemus Nov 4, 2017
b11640c
Fix linting E722: do not use bare except
nicoddemus Nov 4, 2017
fad1fbe
List python 3.6 in the documented supported versions
pagles Nov 8, 2017
f13333a
Create changelog entry
pagles Nov 8, 2017
d904981
Rename 2903.trivial to 2903.doc
pagles Nov 8, 2017
7b1cc55
Merge pull request #2903 from pagles/docs-3.6
The-Compiler Nov 8, 2017
3900879
Mark test_py2_unicode as xfail in PyPy2 on Windows
nicoddemus Nov 9, 2017
c09f69d
Make the "examples" section more prominent in the docs
nicoddemus Nov 9, 2017
e114feb
Mention pytest-lazy-fixture plugin in the proposal for parametrize_wi…
nicoddemus Nov 9, 2017
9fce430
Merge pull request #2907 from nicoddemus/lazy-fixture
RonnyPfannschmidt Nov 10, 2017
b2b1eb2
Merge pull request #2906 from nicoddemus/larger-parametrize-section
RonnyPfannschmidt Nov 10, 2017
66fbebf
Merge pull request #2894 from nicoddemus/fix-linting-errors
nicoddemus Nov 10, 2017
983a09a
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Nov 10, 2017
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 @@ -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