Skip to content
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

Merge master into features and fix flake8 errors #2594

Merged
merged 69 commits into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
8a7d98f
Make YIELD_TEST warning less spammy
pv Jul 10, 2017
73b07e1
Add docs for Item.add_report_section in the docs
nicoddemus Jul 12, 2017
e6b9a81
Add a link to our backwards compatibility policy to our side-bar
nicoddemus Jul 12, 2017
f16c3b9
Merge pull request #2569 from nicoddemus/backwards-sidebar
RonnyPfannschmidt Jul 13, 2017
81cec9f
Merge pull request #2563 from pv/yield-warn-spam
RonnyPfannschmidt Jul 13, 2017
771cedd
Merge pull request #2567 from nicoddemus/add-report-section-docs
RonnyPfannschmidt Jul 13, 2017
97fdc9a
Ensure final collected line doesn't include artifacts
ahartoto Jul 13, 2017
3578f4e
Merge pull request #2571 from ahartoto/master
RonnyPfannschmidt Jul 13, 2017
e5169a0
#2574: --fixtures, --fixtures-per-test keep indentation of docstring
MartinAltmayer Jul 15, 2017
2a97979
Add a changelog entry.
MartinAltmayer Jul 15, 2017
cc39f41
Add myself to AUTHORS as required by the PR help text.
MartinAltmayer Jul 15, 2017
796ffa5
reformatted tox.ini
andras-tim Jul 16, 2017
6af2abd
Fixed flake8 warnings
andras-tim Jul 16, 2017
6146ac9
Fixed E101 flake8 errors
andras-tim Jul 16, 2017
8de49e8
Fixed E111 flake8 errors
andras-tim Jul 16, 2017
64a4b90
Fixed E113 flake8 errors
andras-tim Jul 16, 2017
0be9762
Fixed E121 flake8 errors
andras-tim Jul 16, 2017
425665c
Fixed E122 flake8 errors
andras-tim Jul 16, 2017
4b20b9d
Fixed E123 flake8 errors
andras-tim Jul 16, 2017
051d76a
Fixed E124 flake8 errors
andras-tim Jul 16, 2017
92e2cd9
Fixed E125 flake8 errors
andras-tim Jul 16, 2017
e855a79
Fixed E126 flake8 errors
andras-tim Jul 16, 2017
57438f3
Fixed E127 flake8 errors
andras-tim Jul 16, 2017
cf97159
Fixed E128 flake8 errors
andras-tim Jul 16, 2017
1c935db
Fixed E129 flake8 errors
andras-tim Jul 16, 2017
df54bf0
Fixed E131 flake8 errors
andras-tim Jul 16, 2017
1ff54ba
Fixed E201 flake8 errors
andras-tim Jul 16, 2017
ba0a4d0
Fixed E202 flake8 errors
andras-tim Jul 16, 2017
ebb6d06
Fixed E203 flake8 errors
andras-tim Jul 16, 2017
f640e0c
Fixed E221 flake8 errors
andras-tim Jul 16, 2017
3fabc4d
Fixed E222 flake8 errors
andras-tim Jul 16, 2017
2e8caef
Fixed E225 flake8 errors
andras-tim Jul 16, 2017
4b22f27
Fixed E226 flake8 errors
andras-tim Jul 16, 2017
617e510
Fixed E231 flake8 errors
andras-tim Jul 16, 2017
4c24947
Fixed E241 flake8 errors
andras-tim Jul 16, 2017
b226454
Fixed E251 flake8 errors
andras-tim Jul 16, 2017
8f3eb6d
Fixed E261 flake8 errors
andras-tim Jul 16, 2017
eae8b41
Fixed E262 flake8 errors
andras-tim Jul 16, 2017
195a816
Fixed E265 flake8 errors
andras-tim Jul 16, 2017
c9a081d
Fixed E271 flake8 errors
andras-tim Jul 16, 2017
4730c6d
Fixed E272 flake8 errors
andras-tim Jul 16, 2017
9bad9b5
Fixed E293 flake8 errors
andras-tim Jul 16, 2017
17a21d5
Fixed E301 flake8 errors
andras-tim Jul 16, 2017
b840622
Fixed E302 flake8 errors
andras-tim Jul 16, 2017
7248b75
Fixed E303 flake8 errors
andras-tim Jul 16, 2017
45ac863
Fixed E401 flake8 errors
andras-tim Jul 16, 2017
b9e3188
Fixed E402 flake8 errors
andras-tim Jul 16, 2017
7d2ceb7
Fixed E501 flake8 errors
andras-tim Jul 16, 2017
85141a4
Fixed E701 flake8 errors
andras-tim Jul 16, 2017
bf259d3
Fixed E702 flake8 errors
andras-tim Jul 16, 2017
5ae5927
Fixed E704 flake8 errors
andras-tim Jul 16, 2017
1561028
Fixed E712 flake8 errors
andras-tim Jul 16, 2017
b49e8ba
Fixed E731 flake8 errors
andras-tim Jul 16, 2017
b2a5ec3
updated meta
andras-tim Jul 17, 2017
ac3f220
Merge pull request #2575 from MartinAltmayer/master
nicoddemus Jul 17, 2017
4fd92ef
Merge branch 'fix-flake8-issues' into features
nicoddemus Jul 18, 2017
7b1870a
Fix flake8 in features branch
nicoddemus Jul 18, 2017
bd96b0a
Remove _pytest/impl file
nicoddemus Jul 18, 2017
0e559c9
Merge pull request #2587 from nicoddemus/remove-impl-file
RonnyPfannschmidt Jul 18, 2017
2840634
Fix typo and improve comment about cookiecutter-template
hackebrot Jul 15, 2017
91b4b22
Update documentation for testing plugin code
hackebrot Jul 15, 2017
e73a2f7
Add changelog entry changelog/971.doc
hackebrot Jul 19, 2017
d06d97a
Remove unnecessary comma from docs
hackebrot Jul 19, 2017
1ac02b8
Add plugin code
hackebrot Jul 19, 2017
61d4345
Merge pull request #2593 from hackebrot/extend-pytester-docs-for-test…
nicoddemus Jul 19, 2017
c92760d
Merge branch 'fix-flake8-issues'
nicoddemus Jul 19, 2017
26ee235
Merge remote-tracking branch 'upstream/features' into fix-flake8-errors
nicoddemus Jul 19, 2017
24da938
Fix additional flake8 errors
nicoddemus Jul 19, 2017
d44565f
Merge remote-tracking branch 'upstream/master' into fix-flake8-errors
nicoddemus Jul 19, 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
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Ahn Ki-Wook
Alexander Johnson
Alexei Kozlenok
Anatoly Bubenkoff
Andras Tim
Andreas Zeidler
Andrzej Ostrowski
Andy Freeland
Expand Down Expand Up @@ -104,6 +105,7 @@ Marcin Bachry
Mark Abramowitz
Markus Unterwaditzer
Martijn Faassen
Martin Altmayer
Martin K. Scherer
Martin Prusse
Mathieu Clabaut
Expand Down
7 changes: 5 additions & 2 deletions _pytest/_argcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@
import os
from glob import glob


class FastFilesCompleter:
'Fast file completer class'

def __init__(self, directories=True):
self.directories = directories

def __call__(self, prefix, **kwargs):
"""only called on non option completions"""
if os.path.sep in prefix[1:]: #
if os.path.sep in prefix[1:]:
prefix_dir = len(os.path.dirname(prefix) + os.path.sep)
else:
prefix_dir = 0
Expand Down Expand Up @@ -98,5 +100,6 @@ def __call__(self, prefix, **kwargs):
def try_argcomplete(parser):
argcomplete.autocomplete(parser)
else:
def try_argcomplete(parser): pass
def try_argcomplete(parser):
pass
filescompleter = None
5 changes: 4 additions & 1 deletion _pytest/_code/_py2traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import absolute_import, division, print_function
import types


def format_exception_only(etype, value):
"""Format the exception part of a traceback.

Expand All @@ -30,7 +31,7 @@ def format_exception_only(etype, value):
# would throw another exception and mask the original problem.
if (isinstance(etype, BaseException) or
isinstance(etype, types.InstanceType) or
etype is None or type(etype) is str):
etype is None or type(etype) is str):
return [_format_final_exc_line(etype, value)]

stype = etype.__name__
Expand Down Expand Up @@ -62,6 +63,7 @@ def format_exception_only(etype, value):
lines.append(_format_final_exc_line(stype, value))
return lines


def _format_final_exc_line(etype, value):
"""Return a list of a single line -- normal case for format_exception_only"""
valuestr = _some_str(value)
Expand All @@ -71,6 +73,7 @@ def _format_final_exc_line(etype, value):
line = "%s: %s\n" % (etype, valuestr)
return line


def _some_str(value):
try:
return unicode(value)
Expand Down
69 changes: 41 additions & 28 deletions _pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class Code(object):
""" wrapper around Python code objects """

def __init__(self, rawcode):
if not hasattr(rawcode, "co_filename"):
rawcode = getrawcode(rawcode)
Expand All @@ -26,7 +27,7 @@ def __init__(self, rawcode):
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):
Expand Down Expand Up @@ -82,6 +83,7 @@ def getargs(self, var=False):
argcount += raw.co_flags & CO_VARKEYWORDS
return raw.co_varnames[:argcount]


class Frame(object):
"""Wrapper around a Python frame holding f_locals and f_globals
in which expressions can be evaluated."""
Expand Down Expand Up @@ -119,7 +121,7 @@ def exec_(self, code, **vars):
"""
f_locals = self.f_locals.copy()
f_locals.update(vars)
py.builtin.exec_(code, self.f_globals, f_locals )
py.builtin.exec_(code, self.f_globals, f_locals)

def repr(self, object):
""" return a 'safe' (non-recursive, one-line) string repr for 'object'
Expand All @@ -143,6 +145,7 @@ def getargs(self, var=False):
pass # this can occur when using Psyco
return retval


class TracebackEntry(object):
""" a single entry in a traceback """

Expand All @@ -168,7 +171,7 @@ def relline(self):
return self.lineno - self.frame.code.firstlineno

def __repr__(self):
return "<TracebackEntry %s:%d>" %(self.frame.code.path, self.lineno+1)
return "<TracebackEntry %s:%d>" % (self.frame.code.path, self.lineno + 1)

@property
def statement(self):
Expand Down Expand Up @@ -249,17 +252,19 @@ def __str__(self):
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
name = property(name, None, None, "co_name of underlaying code")


class Traceback(list):
""" Traceback objects encapsulate and offer higher level
access to Traceback entries.
"""
Entry = TracebackEntry

def __init__(self, tb, excinfo=None):
""" initialize from given python traceback object and ExceptionInfo """
self._excinfo = excinfo
Expand Down Expand Up @@ -289,7 +294,7 @@ def cut(self, path=None, lineno=None, firstlineno=None, excludepath=None):
(excludepath is None or not hasattr(codepath, 'relto') or
not codepath.relto(excludepath)) and
(lineno is None or x.lineno == lineno) and
(firstlineno is None or x.frame.code.firstlineno == firstlineno)):
(firstlineno is None or x.frame.code.firstlineno == firstlineno)):
return Traceback(x._rawentry, self._excinfo)
return self

Expand All @@ -315,7 +320,7 @@ def getcrashentry(self):
""" return last non-hidden traceback entry that lead
to the exception of a traceback.
"""
for i in range(-1, -len(self)-1, -1):
for i in range(-1, -len(self) - 1, -1):
entry = self[i]
if not entry.ishidden():
return entry
Expand All @@ -330,17 +335,17 @@ def recursionindex(self):
# id for the code.raw is needed to work around
# the strange metaprogramming in the decorator lib from pypi
# which generates code objects that have hash/value equality
#XXX needs a test
# XXX needs a test
key = entry.frame.code.path, id(entry.frame.code.raw), entry.lineno
#print "checking for recursion at", key
# print "checking for recursion at", key
l = cache.setdefault(key, [])
if l:
f = entry.frame
loc = f.f_locals
for otherloc in l:
if f.is_true(f.eval(co_equal,
__recursioncache_locals_1=loc,
__recursioncache_locals_2=otherloc)):
__recursioncache_locals_1=loc,
__recursioncache_locals_2=otherloc)):
return i
l.append(entry.frame.f_locals)
return None
Expand All @@ -349,6 +354,7 @@ def recursionindex(self):
co_equal = compile('__recursioncache_locals_1 == __recursioncache_locals_2',
'?', 'eval')


class ExceptionInfo(object):
""" wraps sys.exc_info() objects and offers
help for navigating the traceback.
Expand Down Expand Up @@ -405,10 +411,10 @@ def _getreprcrash(self):
exconly = self.exconly(tryshort=True)
entry = self.traceback.getcrashentry()
path, lineno = entry.frame.code.raw.co_filename, entry.lineno
return ReprFileLocation(path, lineno+1, exconly)
return ReprFileLocation(path, lineno + 1, exconly)

def getrepr(self, showlocals=False, style="long",
abspath=False, tbfilter=True, funcargs=False):
abspath=False, tbfilter=True, funcargs=False):
""" return str()able representation of this exception info.
showlocals: show locals per traceback entry
style: long|short|no|native traceback style
Expand All @@ -425,7 +431,7 @@ def getrepr(self, showlocals=False, style="long",
)), self._getreprcrash())

fmt = FormattedExcinfo(showlocals=showlocals, style=style,
abspath=abspath, tbfilter=tbfilter, funcargs=funcargs)
abspath=abspath, tbfilter=tbfilter, funcargs=funcargs)
return fmt.repr_excinfo(self)

def __str__(self):
Expand Down Expand Up @@ -469,7 +475,7 @@ def __init__(self, showlocals=False, style="long", abspath=True, tbfilter=True,
def _getindent(self, source):
# figure out indent for given source
try:
s = str(source.getstatement(len(source)-1))
s = str(source.getstatement(len(source) - 1))
except KeyboardInterrupt:
raise
except:
Expand Down Expand Up @@ -513,7 +519,7 @@ def get_source(self, source, line_index=-1, excinfo=None, short=False):
for line in source.lines[:line_index]:
lines.append(space_prefix + line)
lines.append(self.flow_marker + " " + source.lines[line_index])
for line in source.lines[line_index+1:]:
for line in source.lines[line_index + 1:]:
lines.append(space_prefix + line)
if excinfo is not None:
indent = 4 if short else self._getindent(source)
Expand Down Expand Up @@ -546,10 +552,10 @@ def repr_locals(self, locals):
# _repr() function, which is only reprlib.Repr in
# disguise, so is very configurable.
str_repr = self._saferepr(value)
#if len(str_repr) < 70 or not isinstance(value,
# if len(str_repr) < 70 or not isinstance(value,
# (list, tuple, dict)):
lines.append("%-10s = %s" %(name, str_repr))
#else:
lines.append("%-10s = %s" % (name, str_repr))
# else:
# self._line("%-10s =\\" % (name,))
# # XXX
# py.std.pprint.pprint(value, stream=self.excinfowriter)
Expand All @@ -575,14 +581,14 @@ def repr_traceback_entry(self, entry, excinfo=None):
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)
filelocrepr = ReprFileLocation(path, entry.lineno+1, message)
filelocrepr = ReprFileLocation(path, entry.lineno + 1, message)
localsrepr = None
if not short:
localsrepr = self.repr_locals(entry.locals)
localsrepr = self.repr_locals(entry.locals)
return ReprEntry(lines, reprargs, localsrepr, filelocrepr, style)
if excinfo:
lines.extend(self.get_exconly(excinfo, indent=4))
Expand Down Expand Up @@ -645,7 +651,7 @@ def _truncate_recursive_traceback(self, traceback):
traceback = traceback[:recursionindex + 1]
else:
extraline = None

return traceback, extraline

def repr_excinfo(self, excinfo):
Expand Down Expand Up @@ -699,7 +705,7 @@ def __unicode__(self):
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):
Expand Down Expand Up @@ -743,6 +749,7 @@ def toterminal(self, tw):
self.reprtraceback.toterminal(tw)
super(ReprExceptionInfo, self).toterminal(tw)


class ReprTraceback(TerminalRepr):
entrysep = "_ "

Expand All @@ -758,20 +765,22 @@ def toterminal(self, tw):
tw.line("")
entry.toterminal(tw)
if i < len(self.reprentries) - 1:
next_entry = self.reprentries[i+1]
next_entry = self.reprentries[i + 1]
if entry.style == "long" or \
entry.style == "short" and next_entry.style == "long":
tw.sep(self.entrysep)

if self.extraline:
tw.line(self.extraline)


class ReprTracebackNative(ReprTraceback):
def __init__(self, tblines):
self.style = "native"
self.reprentries = [ReprEntryNative(tblines)]
self.extraline = None


class ReprEntryNative(TerminalRepr):
style = "native"

Expand All @@ -781,6 +790,7 @@ def __init__(self, tblines):
def toterminal(self, tw):
tw.write("".join(self.lines))


class ReprEntry(TerminalRepr):
localssep = "_ "

Expand All @@ -797,15 +807,15 @@ def toterminal(self, tw):
for line in self.lines:
red = line.startswith("E ")
tw.line(line, bold=True, red=red)
#tw.line("")
# tw.line("")
return
if self.reprfuncargs:
self.reprfuncargs.toterminal(tw)
for line in self.lines:
red = line.startswith("E ")
tw.line(line, bold=True, red=red)
if self.reprlocals:
#tw.sep(self.localssep, "Locals")
# tw.sep(self.localssep, "Locals")
tw.line("")
self.reprlocals.toterminal(tw)
if self.reprfileloc:
Expand All @@ -818,6 +828,7 @@ def __str__(self):
self.reprlocals,
self.reprfileloc)


class ReprFileLocation(TerminalRepr):
def __init__(self, path, lineno, message):
self.path = str(path)
Expand All @@ -834,6 +845,7 @@ def toterminal(self, tw):
tw.write(self.path, bold=True, red=True)
tw.line(":%s: %s" % (self.lineno, msg))


class ReprLocals(TerminalRepr):
def __init__(self, lines):
self.lines = lines
Expand All @@ -842,6 +854,7 @@ def toterminal(self, tw):
for line in self.lines:
tw.line(line)


class ReprFuncArgs(TerminalRepr):
def __init__(self, args):
self.args = args
Expand All @@ -850,11 +863,11 @@ def toterminal(self, tw):
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)
linesofar = ns
linesofar = ns
else:
if linesofar:
linesofar += ", " + ns
Expand Down
Loading