Fixed E265 flake8 errors

block comment should start with ‘# ‘
This commit is contained in:
Andras Tim 2017-07-17 01:25:09 +02:00
parent eae8b41b07
commit 195a816522
32 changed files with 97 additions and 97 deletions

View File

@ -330,9 +330,9 @@ class Traceback(list):
# id for the code.raw is needed to work around # id for the code.raw is needed to work around
# the strange metaprogramming in the decorator lib from pypi # the strange metaprogramming in the decorator lib from pypi
# which generates code objects that have hash/value equality # 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 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, []) l = cache.setdefault(key, [])
if l: if l:
f = entry.frame f = entry.frame
@ -546,10 +546,10 @@ class FormattedExcinfo(object):
# _repr() function, which is only reprlib.Repr in # _repr() function, which is only reprlib.Repr in
# disguise, so is very configurable. # disguise, so is very configurable.
str_repr = self._saferepr(value) 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)): # (list, tuple, dict)):
lines.append("%-10s = %s" % (name, str_repr)) lines.append("%-10s = %s" % (name, str_repr))
#else: # else:
# self._line("%-10s =\\" % (name,)) # self._line("%-10s =\\" % (name,))
# # XXX # # XXX
# py.std.pprint.pprint(value, stream=self.excinfowriter) # py.std.pprint.pprint(value, stream=self.excinfowriter)
@ -797,7 +797,7 @@ class ReprEntry(TerminalRepr):
for line in self.lines: for line in self.lines:
red = line.startswith("E ") red = line.startswith("E ")
tw.line(line, bold=True, red=red) tw.line(line, bold=True, red=red)
#tw.line("") # tw.line("")
return return
if self.reprfuncargs: if self.reprfuncargs:
self.reprfuncargs.toterminal(tw) self.reprfuncargs.toterminal(tw)
@ -805,7 +805,7 @@ class ReprEntry(TerminalRepr):
red = line.startswith("E ") red = line.startswith("E ")
tw.line(line, bold=True, red=red) tw.line(line, bold=True, red=red)
if self.reprlocals: if self.reprlocals:
#tw.sep(self.localssep, "Locals") # tw.sep(self.localssep, "Locals")
tw.line("") tw.line("")
self.reprlocals.toterminal(tw) self.reprlocals.toterminal(tw)
if self.reprfileloc: if self.reprfileloc:

View File

@ -143,7 +143,7 @@ class Source(object):
else: else:
source = str(self) source = str(self)
try: try:
#compile(source+'\n', "x", "exec") # compile(source+'\n', "x", "exec")
syntax_checker(source + '\n') syntax_checker(source + '\n')
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise

View File

@ -236,7 +236,7 @@ def cacheshow(config, session):
if ddir.isdir() and ddir.listdir(): if ddir.isdir() and ddir.listdir():
tw.sep("-", "cache directories") tw.sep("-", "cache directories")
for p in sorted(basedir.join("d").visit()): for p in sorted(basedir.join("d").visit()):
#if p.check(dir=1): # if p.check(dir=1):
# print("%s/" % p.relto(basedir)) # print("%s/" % p.relto(basedir))
if p.isfile(): if p.isfile():
key = p.relto(basedir) key = p.relto(basedir)

View File

@ -134,7 +134,7 @@ class CaptureManager:
self.resumecapture() self.resumecapture()
self.activate_funcargs(item) self.activate_funcargs(item)
yield yield
#self.deactivate_funcargs() called from suspendcapture() # self.deactivate_funcargs() called from suspendcapture()
self.suspendcapture_item(item, "call") self.suspendcapture_item(item, "call")
@pytest.hookimpl(hookwrapper=True) @pytest.hookimpl(hookwrapper=True)

View File

@ -85,7 +85,7 @@ def num_mock_patch_args(function):
def getfuncargnames(function, startindex=None): def getfuncargnames(function, startindex=None):
# XXX merge with main.py's varnames # XXX merge with main.py's varnames
#assert not isclass(function) # assert not isclass(function)
realfunction = function realfunction = function
while hasattr(realfunction, "__wrapped__"): while hasattr(realfunction, "__wrapped__"):
realfunction = realfunction.__wrapped__ realfunction = realfunction.__wrapped__

View File

@ -693,7 +693,7 @@ class Argument:
if self._attrs.get('help'): if self._attrs.get('help'):
a = self._attrs['help'] a = self._attrs['help']
a = a.replace('%default', '%(default)s') a = a.replace('%default', '%(default)s')
#a = a.replace('%prog', '%(prog)s') # a = a.replace('%prog', '%(prog)s')
self._attrs['help'] = a self._attrs['help'] = a
return self._attrs return self._attrs
@ -1361,7 +1361,7 @@ def setns(obj, dic):
else: else:
setattr(obj, name, value) setattr(obj, name, value)
obj.__all__.append(name) obj.__all__.append(name)
#if obj != pytest: # if obj != pytest:
# pytest.__all__.append(name) # pytest.__all__.append(name)
setattr(pytest, name, value) setattr(pytest, name, value)

View File

@ -32,11 +32,11 @@ def pytest_addoption(parser):
type="args", default=['.*', 'build', 'dist', 'CVS', '_darcs', '{arch}', '*.egg', 'venv']) type="args", default=['.*', 'build', 'dist', 'CVS', '_darcs', '{arch}', '*.egg', 'venv'])
parser.addini("testpaths", "directories to search for tests when no files or directories are given in the command line.", parser.addini("testpaths", "directories to search for tests when no files or directories are given in the command line.",
type="args", default=[]) type="args", default=[])
#parser.addini("dirpatterns", # parser.addini("dirpatterns",
# "patterns specifying possible locations of test files", # "patterns specifying possible locations of test files",
# type="linelist", default=["**/test_*.txt", # type="linelist", default=["**/test_*.txt",
# "**/test_*.py", "**/*_test.py"] # "**/test_*.py", "**/*_test.py"]
#) # )
group = parser.getgroup("general", "running and selection options") group = parser.getgroup("general", "running and selection options")
group._addoption('-x', '--exitfirst', action="store_const", group._addoption('-x', '--exitfirst', action="store_const",
dest="maxfail", const=1, dest="maxfail", const=1,

View File

@ -38,14 +38,14 @@ def pytest_runtest_setup(item):
if not call_optional(item.obj, 'setup'): if not call_optional(item.obj, 'setup'):
# call module level setup if there is no object level one # call module level setup if there is no object level one
call_optional(item.parent.obj, 'setup') call_optional(item.parent.obj, 'setup')
#XXX this implies we only call teardown when setup worked # XXX this implies we only call teardown when setup worked
item.session._setupstate.addfinalizer((lambda: teardown_nose(item)), item) item.session._setupstate.addfinalizer((lambda: teardown_nose(item)), item)
def teardown_nose(item): def teardown_nose(item):
if is_potential_nosetest(item): if is_potential_nosetest(item):
if not call_optional(item.obj, 'teardown'): if not call_optional(item.obj, 'teardown'):
call_optional(item.parent.obj, 'teardown') call_optional(item.parent.obj, 'teardown')
#if hasattr(item.parent, '_nosegensetup'): # if hasattr(item.parent, '_nosegensetup'):
# #call_optional(item._nosegensetup, 'teardown') # #call_optional(item._nosegensetup, 'teardown')
# del item.parent._nosegensetup # del item.parent._nosegensetup

View File

@ -496,7 +496,7 @@ class Testdir:
source_unicode = "\n".join([my_totext(line) for line in source.lines]) source_unicode = "\n".join([my_totext(line) for line in source.lines])
source = py.builtin._totext(source_unicode) source = py.builtin._totext(source_unicode)
content = source.strip().encode(encoding) # + "\n" content = source.strip().encode(encoding) # + "\n"
#content = content.rstrip() + "\n" # content = content.rstrip() + "\n"
p.write(content, "wb") p.write(content, "wb")
if ret is None: if ret is None:
ret = p ret = p
@ -779,11 +779,11 @@ class Testdir:
args = [str(x) for x in args] args = [str(x) for x in args]
for x in args: for x in args:
if str(x).startswith('--basetemp'): if str(x).startswith('--basetemp'):
#print ("basedtemp exists: %s" %(args,)) # print("basedtemp exists: %s" %(args,))
break break
else: else:
args.append("--basetemp=%s" % self.tmpdir.dirpath('basetemp')) args.append("--basetemp=%s" % self.tmpdir.dirpath('basetemp'))
#print ("added basetemp: %s" %(args,)) # print("added basetemp: %s" %(args,))
return args return args
def parseconfig(self, *args): def parseconfig(self, *args):
@ -989,10 +989,10 @@ class Testdir:
p = py.path.local.make_numbered_dir(prefix="runpytest-", p = py.path.local.make_numbered_dir(prefix="runpytest-",
keep=None, rootdir=self.tmpdir) keep=None, rootdir=self.tmpdir)
args = ('--basetemp=%s' % p, ) + args args = ('--basetemp=%s' % p, ) + args
#for x in args: # for x in args:
# if '--confcutdir' in str(x): # if '--confcutdir' in str(x):
# break # break
#else: # else:
# pass # pass
# args = ('--confcutdir=.',) + args # args = ('--confcutdir=.',) + args
plugins = [x for x in self.plugins if isinstance(x, str)] plugins = [x for x in self.plugins if isinstance(x, str)]

View File

@ -320,7 +320,7 @@ class PyCollector(PyobjMixin, main.Collector):
return l return l
def makeitem(self, name, obj): def makeitem(self, name, obj):
#assert self.ihook.fspath == self.fspath, self # assert self.ihook.fspath == self.fspath, self
return self.ihook.pytest_pycollect_makeitem( return self.ihook.pytest_pycollect_makeitem(
collector=self, name=name, obj=obj) collector=self, name=name, obj=obj)
@ -563,7 +563,7 @@ class FunctionMixin(PyobjMixin):
if ntraceback == traceback: if ntraceback == traceback:
ntraceback = ntraceback.cut(path=path) ntraceback = ntraceback.cut(path=path)
if ntraceback == traceback: if ntraceback == traceback:
#ntraceback = ntraceback.cut(excludepath=cutdir2) # ntraceback = ntraceback.cut(excludepath=cutdir2)
ntraceback = ntraceback.filter(filter_traceback) ntraceback = ntraceback.filter(filter_traceback)
if not ntraceback: if not ntraceback:
ntraceback = traceback ntraceback = traceback
@ -1213,7 +1213,7 @@ def raises(expected_exception, *args, **kwargs):
frame = sys._getframe(1) frame = sys._getframe(1)
loc = frame.f_locals.copy() loc = frame.f_locals.copy()
loc.update(kwargs) loc.update(kwargs)
#print "raises frame scope: %r" % frame.f_locals # print "raises frame scope: %r" % frame.f_locals
try: try:
code = _pytest._code.Source(code).compile() code = _pytest._code.Source(code).compile()
py.builtin.exec_(code, frame.f_globals, loc) py.builtin.exec_(code, frame.f_globals, loc)

View File

@ -386,7 +386,7 @@ class SetupState(object):
""" """
assert colitem and not isinstance(colitem, tuple) assert colitem and not isinstance(colitem, tuple)
assert py.builtin.callable(finalizer) assert py.builtin.callable(finalizer)
#assert colitem in self.stack # some unit tests don't setup stack :/ # assert colitem in self.stack # some unit tests don't setup stack :/
self._finalizers.setdefault(colitem, []).append(finalizer) self._finalizers.setdefault(colitem, []).append(finalizer)
def _pop_and_teardown(self): def _pop_and_teardown(self):

View File

@ -280,7 +280,7 @@ def pytest_report_teststatus(report):
def pytest_terminal_summary(terminalreporter): def pytest_terminal_summary(terminalreporter):
tr = terminalreporter tr = terminalreporter
if not tr.reportchars: if not tr.reportchars:
#for name in "xfailed skipped failed xpassed": # for name in "xfailed skipped failed xpassed":
# if not tr.stats.get(name, 0): # if not tr.stats.get(name, 0):
# tr.write_line("HINT: use '-r' option to see extra " # tr.write_line("HINT: use '-r' option to see extra "
# "summary info about tests") # "summary info about tests")
@ -364,14 +364,14 @@ def show_skipped(terminalreporter, lines):
tr = terminalreporter tr = terminalreporter
skipped = tr.stats.get('skipped', []) skipped = tr.stats.get('skipped', [])
if skipped: if skipped:
#if not tr.hasopt('skipped'): # if not tr.hasopt('skipped'):
# tr.write_line( # tr.write_line(
# "%d skipped tests, specify -rs for more info" % # "%d skipped tests, specify -rs for more info" %
# len(skipped)) # len(skipped))
# return # return
fskips = folded_skips(skipped) fskips = folded_skips(skipped)
if fskips: if fskips:
#tr.write_sep("_", "skipped test summary") # tr.write_sep("_", "skipped test summary")
for num, fspath, lineno, reason in fskips: for num, fspath, lineno, reason in fskips:
if reason.startswith("Skipped: "): if reason.startswith("Skipped: "):
reason = reason[9:] reason = reason[9:]

View File

@ -248,7 +248,7 @@ class TerminalReporter:
line = self._locationline(rep.nodeid, *rep.location) line = self._locationline(rep.nodeid, *rep.location)
if not hasattr(rep, 'node'): if not hasattr(rep, 'node'):
self.write_ensure_prefix(line, word, **markup) self.write_ensure_prefix(line, word, **markup)
#self._tw.write(word, **markup) # self._tw.write(word, **markup)
else: else:
self.ensure_newline() self.ensure_newline()
if hasattr(rep, 'node'): if hasattr(rep, 'node'):
@ -269,7 +269,7 @@ class TerminalReporter:
items = [x for x in report.result if isinstance(x, pytest.Item)] items = [x for x in report.result if isinstance(x, pytest.Item)]
self._numcollected += len(items) self._numcollected += len(items)
if self.isatty: if self.isatty:
#self.write_fspath_result(report.nodeid, 'E') # self.write_fspath_result(report.nodeid, 'E')
self.report_collect() self.report_collect()
def report_collect(self, final=False): def report_collect(self, final=False):
@ -347,7 +347,7 @@ class TerminalReporter:
return 0 return 0
if not self.showheader: if not self.showheader:
return return
#for i, testarg in enumerate(self.config.args): # for i, testarg in enumerate(self.config.args):
# self.write_line("test path %d: %s" %(i+1, testarg)) # self.write_line("test path %d: %s" %(i+1, testarg))
def _printcollecteditems(self, items): def _printcollecteditems(self, items):
@ -378,7 +378,7 @@ class TerminalReporter:
stack.pop() stack.pop()
for col in needed_collectors[len(stack):]: for col in needed_collectors[len(stack):]:
stack.append(col) stack.append(col)
#if col.name == "()": # if col.name == "()":
# continue # continue
indent = (len(stack) - 1) * " " indent = (len(stack) - 1) * " "
self._tw.line("%s%s" % (indent, col)) self._tw.line("%s%s" % (indent, col))

View File

@ -25,7 +25,7 @@ class TempdirFactory:
provides an empty unique-per-test-invocation directory provides an empty unique-per-test-invocation directory
and is guaranteed to be empty. and is guaranteed to be empty.
""" """
#py.log._apiwarn(">1.1", "use tmpdir function argument") # py.log._apiwarn(">1.1", "use tmpdir function argument")
return self.getbasetemp().ensure(string, dir=dir) return self.getbasetemp().ensure(string, dir=dir)
def mktemp(self, basename, numbered=True): def mktemp(self, basename, numbered=True):

View File

@ -119,7 +119,7 @@ class TestGeneralUsage(object):
testdir.makepyfile(import_fails="import does_not_work") testdir.makepyfile(import_fails="import does_not_work")
result = testdir.runpytest(p) result = testdir.runpytest(p)
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
#XXX on jython this fails: "> import import_fails", # XXX on jython this fails: "> import import_fails",
"ImportError while importing test module*", "ImportError while importing test module*",
"*No module named *does_not_work*", "*No module named *does_not_work*",
]) ])
@ -440,8 +440,8 @@ class TestInvocationVariants(object):
#collect #collect
#cmdline #cmdline
#Item #Item
#assert collect.Item is Item # assert collect.Item is Item
#assert collect.Collector is Collector # assert collect.Collector is Collector
main main
skip skip
xfail xfail

View File

@ -72,9 +72,9 @@ def test_excinfo_getstatement():
l = list(excinfo.traceback) l = list(excinfo.traceback)
foundlinenumbers = [x.lineno for x in l] foundlinenumbers = [x.lineno for x in l]
assert foundlinenumbers == linenumbers assert foundlinenumbers == linenumbers
#for x in info: # for x in info:
# print "%s:%d %s" %(x.path.relto(root), x.lineno, x.statement) # print "%s:%d %s" %(x.path.relto(root), x.lineno, x.statement)
#xxx # xxx
# testchain for getentries test below # testchain for getentries test below
def f(): def f():
@ -238,7 +238,7 @@ class TestTraceback_f_g_h(object):
assert recindex is None assert recindex is None
def test_traceback_messy_recursion(self): def test_traceback_messy_recursion(self):
#XXX: simplified locally testable version # XXX: simplified locally testable version
decorator = pytest.importorskip('decorator').decorator decorator = pytest.importorskip('decorator').decorator
def log(f, *k, **kw): def log(f, *k, **kw):
@ -331,7 +331,7 @@ def test_excinfo_no_sourcecode():
assert s == " File '<string>':1 in <module>\n ???\n" assert s == " File '<string>':1 in <module>\n ???\n"
def test_excinfo_no_python_sourcecode(tmpdir): def test_excinfo_no_python_sourcecode(tmpdir):
#XXX: simplified locally testable version # XXX: simplified locally testable version
tmpdir.join('test.txt').write("{{ h()}}:") tmpdir.join('test.txt').write("{{ h()}}:")
jinja2 = pytest.importorskip('jinja2') jinja2 = pytest.importorskip('jinja2')
@ -575,7 +575,7 @@ raise ValueError()
loc = repr_entry.reprfileloc loc = repr_entry.reprfileloc
assert loc.path == mod.__file__ assert loc.path == mod.__file__
assert loc.lineno == 3 assert loc.lineno == 3
#assert loc.message == "ValueError: hello" # assert loc.message == "ValueError: hello"
def test_repr_tracebackentry_lines2(self, importasmod): def test_repr_tracebackentry_lines2(self, importasmod):
mod = importasmod(""" mod = importasmod("""

View File

@ -181,16 +181,16 @@ class TestSourceParsingAndCompiling(object):
assert 'ValueError' in source2 assert 'ValueError' in source2
def test_getstatement(self): def test_getstatement(self):
#print str(self.source) # print str(self.source)
ass = str(self.source[1:]) ass = str(self.source[1:])
for i in range(1, 4): for i in range(1, 4):
#print "trying start in line %r" % self.source[i] # print "trying start in line %r" % self.source[i]
s = self.source.getstatement(i) s = self.source.getstatement(i)
#x = s.deindent() #x = s.deindent()
assert str(s) == ass assert str(s) == ass
def test_getstatementrange_triple_quoted(self): def test_getstatementrange_triple_quoted(self):
#print str(self.source) # print str(self.source)
source = Source("""hello(''' source = Source("""hello('''
''')""") ''')""")
s = source.getstatement(0) s = source.getstatement(0)
@ -211,12 +211,12 @@ class TestSourceParsingAndCompiling(object):
""") """)
assert len(source) == 7 assert len(source) == 7
# check all lineno's that could occur in a traceback # check all lineno's that could occur in a traceback
#assert source.getstatementrange(0) == (0, 7) # assert source.getstatementrange(0) == (0, 7)
#assert source.getstatementrange(1) == (1, 5) # assert source.getstatementrange(1) == (1, 5)
assert source.getstatementrange(2) == (2, 3) assert source.getstatementrange(2) == (2, 3)
assert source.getstatementrange(3) == (3, 4) assert source.getstatementrange(3) == (3, 4)
assert source.getstatementrange(4) == (4, 5) assert source.getstatementrange(4) == (4, 5)
#assert source.getstatementrange(5) == (0, 7) # assert source.getstatementrange(5) == (0, 7)
assert source.getstatementrange(6) == (6, 7) assert source.getstatementrange(6) == (6, 7)
def test_getstatementrange_bug(self): def test_getstatementrange_bug(self):
@ -283,7 +283,7 @@ class TestSourceParsingAndCompiling(object):
excinfo = pytest.raises(AssertionError, "f(6)") excinfo = pytest.raises(AssertionError, "f(6)")
frame = excinfo.traceback[-1].frame frame = excinfo.traceback[-1].frame
stmt = frame.code.fullsource.getstatement(frame.lineno) stmt = frame.code.fullsource.getstatement(frame.lineno)
#print "block", str(block) # print "block", str(block)
assert str(stmt).strip().startswith('assert') assert str(stmt).strip().startswith('assert')
@pytest.mark.parametrize('name', ['', None, 'my']) @pytest.mark.parametrize('name', ['', None, 'my'])

View File

@ -2373,7 +2373,7 @@ class TestFixtureMarker(object):
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l l = reprec.getcalls("pytest_runtest_call")[0].item.module.l
import pprint import pprint
pprint.pprint(l) pprint.pprint(l)
#assert len(l) == 6 # assert len(l) == 6
assert l[0] == l[1] == 1 assert l[0] == l[1] == 1
assert l[2] == "fin1" assert l[2] == "fin1"
assert l[3] == l[4] == 2 assert l[3] == l[4] == 2

View File

@ -822,7 +822,7 @@ def test_traceback_failure(testdir):
"", "",
"*test_*.py:6: ", "*test_*.py:6: ",
"_ _ _ *", "_ _ _ *",
#"", # "",
" def f(x):", " def f(x):",
"> assert x == g()", "> assert x == g()",
"E assert 3 == 2", "E assert 3 == 2",

View File

@ -234,7 +234,7 @@ class TestPerTestCapturing(object):
"setup func1*", "setup func1*",
"in func1*", "in func1*",
"teardown func1*", "teardown func1*",
#"*1 fixture failure*" # "*1 fixture failure*"
]) ])
def test_teardown_capturing_final(self, testdir): def test_teardown_capturing_final(self, testdir):

View File

@ -362,9 +362,9 @@ class TestSession(object):
topdir = testdir.tmpdir topdir = testdir.tmpdir
rcol = Session(config) rcol = Session(config)
assert topdir == rcol.fspath assert topdir == rcol.fspath
#rootid = rcol.nodeid # rootid = rcol.nodeid
#root2 = rcol.perform_collect([rcol.nodeid], genitems=False)[0] # root2 = rcol.perform_collect([rcol.nodeid], genitems=False)[0]
#assert root2 == rcol, rootid # assert root2 == rcol, rootid
colitems = rcol.perform_collect([rcol.nodeid], genitems=False) colitems = rcol.perform_collect([rcol.nodeid], genitems=False)
assert len(colitems) == 1 assert len(colitems) == 1
assert colitems[0].fspath == p assert colitems[0].fspath == p

View File

@ -43,7 +43,7 @@ class TestConftestValueAccessGlobal(object):
len(conftest._path2confmods) len(conftest._path2confmods)
conftest._getconftestmodules(basedir) conftest._getconftestmodules(basedir)
snap1 = len(conftest._path2confmods) snap1 = len(conftest._path2confmods)
#assert len(conftest._path2confmods) == snap1 + 1 # assert len(conftest._path2confmods) == snap1 + 1
conftest._getconftestmodules(basedir.join('adir')) conftest._getconftestmodules(basedir.join('adir'))
assert len(conftest._path2confmods) == snap1 + 1 assert len(conftest._path2confmods) == snap1 + 1
conftest._getconftestmodules(basedir.join('b')) conftest._getconftestmodules(basedir.join('b'))

View File

@ -19,7 +19,7 @@ class TestDoctests(object):
""") """)
for x in (testdir.tmpdir, checkfile): for x in (testdir.tmpdir, checkfile):
#print "checking that %s returns custom items" % (x,) # print "checking that %s returns custom items" % (x,)
items, reprec = testdir.inline_genitems(x) items, reprec = testdir.inline_genitems(x)
assert len(items) == 1 assert len(items) == 1
assert isinstance(items[0], DoctestItem) assert isinstance(items[0], DoctestItem)

View File

@ -5,7 +5,7 @@ import pytest
def test_version(testdir, pytestconfig): def test_version(testdir, pytestconfig):
result = testdir.runpytest("--version") result = testdir.runpytest("--version")
assert result.ret == 0 assert result.ret == 0
#p = py.path.local(py.__file__).dirpath() # p = py.path.local(py.__file__).dirpath()
result.stderr.fnmatch_lines([ result.stderr.fnmatch_lines([
'*pytest*%s*imported from*' % (pytest.__version__, ) '*pytest*%s*imported from*' % (pytest.__version__, )
]) ])

View File

@ -181,7 +181,7 @@ class TestPDB(object):
xxx xxx
""") """)
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
#child.expect(".*import pytest.*") # child.expect(".*import pytest.*")
child.expect("(Pdb)") child.expect("(Pdb)")
child.sendeof() child.sendeof()
child.expect("1 error") child.expect("1 error")
@ -194,7 +194,7 @@ class TestPDB(object):
""") """)
p1 = testdir.makepyfile("def test_func(): pass") p1 = testdir.makepyfile("def test_func(): pass")
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
#child.expect(".*import pytest.*") # child.expect(".*import pytest.*")
child.expect("(Pdb)") child.expect("(Pdb)")
child.sendeof() child.sendeof()
self.flush(child) self.flush(child)

View File

@ -31,7 +31,7 @@ class TestPytestPluginInteractions(object):
pm.hook.pytest_addhooks.call_historic( pm.hook.pytest_addhooks.call_historic(
kwargs=dict(pluginmanager=config.pluginmanager)) kwargs=dict(pluginmanager=config.pluginmanager))
config.pluginmanager._importconftest(conf) config.pluginmanager._importconftest(conf)
#print(config.pluginmanager.get_plugins()) # print(config.pluginmanager.get_plugins())
res = config.hook.pytest_myhook(xyz=10) res = config.hook.pytest_myhook(xyz=10)
assert res == [11] assert res == [11]
@ -232,7 +232,7 @@ class TestPytestPluginManager(object):
assert mod in l assert mod in l
pytest.raises(ValueError, "pm.register(mod)") pytest.raises(ValueError, "pm.register(mod)")
pytest.raises(ValueError, lambda: pm.register(mod)) pytest.raises(ValueError, lambda: pm.register(mod))
#assert not pm.is_registered(mod2) # assert not pm.is_registered(mod2)
assert pm.get_plugins() == l assert pm.get_plugins() == l
def test_canonical_import(self, monkeypatch): def test_canonical_import(self, monkeypatch):
@ -259,7 +259,7 @@ class TestPytestPluginManager(object):
mod.pytest_plugins = "pytest_a" mod.pytest_plugins = "pytest_a"
aplugin = testdir.makepyfile(pytest_a="#") aplugin = testdir.makepyfile(pytest_a="#")
reprec = testdir.make_hook_recorder(pytestpm) reprec = testdir.make_hook_recorder(pytestpm)
#syspath.prepend(aplugin.dirpath()) # syspath.prepend(aplugin.dirpath())
py.std.sys.path.insert(0, str(aplugin.dirpath())) py.std.sys.path.insert(0, str(aplugin.dirpath()))
pytestpm.consider_module(mod) pytestpm.consider_module(mod)
call = reprec.getcall(pytestpm.hook.pytest_plugin_registered.name) call = reprec.getcall(pytestpm.hook.pytest_plugin_registered.name)

View File

@ -14,7 +14,7 @@ def test_generic_path(testdir):
config = testdir.parseconfig() config = testdir.parseconfig()
session = Session(config) session = Session(config)
p1 = Node('a', config=config, session=session) p1 = Node('a', config=config, session=session)
#assert p1.fspath is None # assert p1.fspath is None
p2 = Node('B', parent=p1) p2 = Node('B', parent=p1)
p3 = Node('()', parent=p2) p3 = Node('()', parent=p2)
item = Item('c', parent=p3) item = Item('c', parent=p3)

View File

@ -94,7 +94,7 @@ class BaseFunctionalTests(object):
assert rep.failed assert rep.failed
assert rep.when == "call" assert rep.when == "call"
assert rep.outcome == "failed" assert rep.outcome == "failed"
#assert isinstance(rep.longrepr, ReprExceptionInfo) # assert isinstance(rep.longrepr, ReprExceptionInfo)
def test_skipfunction(self, testdir): def test_skipfunction(self, testdir):
reports = testdir.runitem(""" reports = testdir.runitem("""
@ -107,12 +107,12 @@ class BaseFunctionalTests(object):
assert not rep.passed assert not rep.passed
assert rep.skipped assert rep.skipped
assert rep.outcome == "skipped" assert rep.outcome == "skipped"
#assert rep.skipped.when == "call" # assert rep.skipped.when == "call"
#assert rep.skipped.when == "call" # assert rep.skipped.when == "call"
#assert rep.skipped == "%sreason == "hello" # assert rep.skipped == "%sreason == "hello"
#assert rep.skipped.location.lineno == 3 # assert rep.skipped.location.lineno == 3
#assert rep.skipped.location.path # assert rep.skipped.location.path
#assert not rep.skipped.failurerepr # assert not rep.skipped.failurerepr
def test_skip_in_setup_function(self, testdir): def test_skip_in_setup_function(self, testdir):
reports = testdir.runitem(""" reports = testdir.runitem("""
@ -127,9 +127,9 @@ class BaseFunctionalTests(object):
assert not rep.failed assert not rep.failed
assert not rep.passed assert not rep.passed
assert rep.skipped assert rep.skipped
#assert rep.skipped.reason == "hello" # assert rep.skipped.reason == "hello"
#assert rep.skipped.location.lineno == 3 # assert rep.skipped.location.lineno == 3
#assert rep.skipped.location.lineno == 3 # assert rep.skipped.location.lineno == 3
assert len(reports) == 2 assert len(reports) == 2
assert reports[1].passed # teardown assert reports[1].passed # teardown
@ -163,8 +163,8 @@ class BaseFunctionalTests(object):
assert not rep.passed assert not rep.passed
assert rep.failed assert rep.failed
assert rep.when == "teardown" assert rep.when == "teardown"
#assert rep.longrepr.reprcrash.lineno == 3 # assert rep.longrepr.reprcrash.lineno == 3
#assert rep.longrepr.reprtraceback.reprentries # assert rep.longrepr.reprtraceback.reprentries
def test_custom_failure_repr(self, testdir): def test_custom_failure_repr(self, testdir):
testdir.makepyfile(conftest=""" testdir.makepyfile(conftest="""
@ -182,10 +182,10 @@ class BaseFunctionalTests(object):
assert not rep.skipped assert not rep.skipped
assert not rep.passed assert not rep.passed
assert rep.failed assert rep.failed
#assert rep.outcome.when == "call" # assert rep.outcome.when == "call"
#assert rep.failed.where.lineno == 3 # assert rep.failed.where.lineno == 3
#assert rep.failed.where.path.basename == "test_func.py" # assert rep.failed.where.path.basename == "test_func.py"
#assert rep.failed.failurerepr == "hello" # assert rep.failed.failurerepr == "hello"
def test_teardown_final_returncode(self, testdir): def test_teardown_final_returncode(self, testdir):
rec = testdir.inline_runsource(""" rec = testdir.inline_runsource("""
@ -287,10 +287,10 @@ class BaseFunctionalTests(object):
assert not rep.skipped assert not rep.skipped
assert not rep.passed assert not rep.passed
assert rep.failed assert rep.failed
#assert rep.outcome.when == "setup" # assert rep.outcome.when == "setup"
#assert rep.outcome.where.lineno == 3 # assert rep.outcome.where.lineno == 3
#assert rep.outcome.where.path.basename == "test_func.py" # assert rep.outcome.where.path.basename == "test_func.py"
#assert instanace(rep.failed.failurerepr, PythonFailureRepr) # assert instanace(rep.failed.failurerepr, PythonFailureRepr)
def test_systemexit_does_not_bail_out(self, testdir): def test_systemexit_does_not_bail_out(self, testdir):
try: try:
@ -540,8 +540,8 @@ def test_importorskip(monkeypatch):
try: try:
sys = importorskip("sys") # noqa sys = importorskip("sys") # noqa
assert sys == py.std.sys assert sys == py.std.sys
#path = pytest.importorskip("os.path") # path = pytest.importorskip("os.path")
#assert path == py.std.os.path # assert path == py.std.os.path
excinfo = pytest.raises(pytest.skip.Exception, f) excinfo = pytest.raises(pytest.skip.Exception, f)
path = py.path.local(excinfo.getrepr().reprcrash.path) path = py.path.local(excinfo.getrepr().reprcrash.path)
# check that importorskip reports the actual call # check that importorskip reports the actual call

View File

@ -27,9 +27,9 @@ class SessionTests(object):
itemstarted = reprec.getcalls("pytest_itemcollected") itemstarted = reprec.getcalls("pytest_itemcollected")
assert len(itemstarted) == 4 assert len(itemstarted) == 4
# XXX check for failing funcarg setup # XXX check for failing funcarg setup
#colreports = reprec.getcalls("pytest_collectreport") # colreports = reprec.getcalls("pytest_collectreport")
#assert len(colreports) == 4 # assert len(colreports) == 4
#assert colreports[1].report.failed # assert colreports[1].report.failed
def test_nested_import_error(self, testdir): def test_nested_import_error(self, testdir):
tfile = testdir.makepyfile(""" tfile = testdir.makepyfile("""
@ -211,9 +211,9 @@ def test_plugin_specify(testdir):
pytest.raises(ImportError, """ pytest.raises(ImportError, """
testdir.parseconfig("-p", "nqweotexistent") testdir.parseconfig("-p", "nqweotexistent")
""") """)
#pytest.raises(ImportError, # pytest.raises(ImportError,
# "config.do_configure(config)" # "config.do_configure(config)"
#) # )
def test_plugin_already_exists(testdir): def test_plugin_already_exists(testdir):
config = testdir.parseconfig("-p", "terminal") config = testdir.parseconfig("-p", "terminal")

View File

@ -207,9 +207,9 @@ class TestXFail(object):
assert 0 assert 0
""") """)
testdir.runpytest(p, '-v') testdir.runpytest(p, '-v')
#result.stdout.fnmatch_lines([ # result.stdout.fnmatch_lines([
# "*HINT*use*-r*" # "*HINT*use*-r*"
#]) # ])
def test_xfail_not_run_xfail_reporting(self, testdir): def test_xfail_not_run_xfail_reporting(self, testdir):
p = testdir.makepyfile(test_one=""" p = testdir.makepyfile(test_one="""
@ -640,7 +640,7 @@ def test_skip_not_report_default(testdir):
""") """)
result = testdir.runpytest(p, '-v') result = testdir.runpytest(p, '-v')
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
#"*HINT*use*-r*", # "*HINT*use*-r*",
"*1 skipped*", "*1 skipped*",
]) ])

View File

@ -264,13 +264,13 @@ class TestCollectonly(object):
pass pass
""") """)
result = testdir.runpytest("--collect-only", p) result = testdir.runpytest("--collect-only", p)
#assert stderr.startswith("inserting into sys.path") # assert stderr.startswith("inserting into sys.path")
assert result.ret == 0 assert result.ret == 0
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
"*<Module '*.py'>", "*<Module '*.py'>",
"* <Function 'test_func1'*>", "* <Function 'test_func1'*>",
"* <Class 'TestClass'>", "* <Class 'TestClass'>",
#"* <Instance '()'>", # "* <Instance '()'>",
"* <Function 'test_method'*>", "* <Function 'test_method'*>",
]) ])
@ -485,7 +485,7 @@ class TestTerminalFunctional(object):
""") """)
result = testdir.runpytest(p1, '-l') result = testdir.runpytest(p1, '-l')
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
#"_ _ * Locals *", # "_ _ * Locals *",
"x* = 3", "x* = 3",
"y* = 'xxxxxx*" "y* = 'xxxxxx*"
]) ])

View File

@ -196,6 +196,6 @@ filterwarnings =
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
[flake8] [flake8]
ignore = E265,E271,E272,E293,E301,E302,E303,E401,E402,E501,E701,E702,E704,E712,E731 ignore = E271,E272,E293,E301,E302,E303,E401,E402,E501,E701,E702,E704,E712,E731
max-line-length = 120 max-line-length = 120
exclude = _pytest/vendored_packages/pluggy.py exclude = _pytest/vendored_packages/pluggy.py