Fixed E231 flake8 errors
missing whitespace after ‘,’, ‘;’, or ‘:’
This commit is contained in:
parent
4b22f270a3
commit
617e510b6e
|
@ -165,7 +165,7 @@ class Source(object):
|
||||||
if not filename or py.path.local(filename).check(file=0):
|
if not filename or py.path.local(filename).check(file=0):
|
||||||
if _genframe is None:
|
if _genframe is None:
|
||||||
_genframe = sys._getframe(1) # the caller
|
_genframe = sys._getframe(1) # the caller
|
||||||
fn,lineno = _genframe.f_code.co_filename, _genframe.f_lineno
|
fn, lineno = _genframe.f_code.co_filename, _genframe.f_lineno
|
||||||
base = "<%d-codegen " % self._compilecounter
|
base = "<%d-codegen " % self._compilecounter
|
||||||
self.__class__._compilecounter += 1
|
self.__class__._compilecounter += 1
|
||||||
if not filename:
|
if not filename:
|
||||||
|
@ -337,7 +337,7 @@ def get_statement_startend2(lineno, node):
|
||||||
def getstatementrange_ast(lineno, source, assertion=False, astnode=None):
|
def getstatementrange_ast(lineno, source, assertion=False, astnode=None):
|
||||||
if astnode is None:
|
if astnode is None:
|
||||||
content = str(source)
|
content = str(source)
|
||||||
if sys.version_info < (2,7):
|
if sys.version_info < (2, 7):
|
||||||
content += "\n"
|
content += "\n"
|
||||||
try:
|
try:
|
||||||
astnode = compile(content, "source", "exec", 1024) # 1024 for AST
|
astnode = compile(content, "source", "exec", 1024) # 1024 for AST
|
||||||
|
|
|
@ -36,10 +36,10 @@ PYC_TAIL = "." + PYTEST_TAG + PYC_EXT
|
||||||
REWRITE_NEWLINES = sys.version_info[:2] != (2, 7) and sys.version_info < (3, 2)
|
REWRITE_NEWLINES = sys.version_info[:2] != (2, 7) and sys.version_info < (3, 2)
|
||||||
ASCII_IS_DEFAULT_ENCODING = sys.version_info[0] < 3
|
ASCII_IS_DEFAULT_ENCODING = sys.version_info[0] < 3
|
||||||
|
|
||||||
if sys.version_info >= (3,5):
|
if sys.version_info >= (3, 5):
|
||||||
ast_Call = ast.Call
|
ast_Call = ast.Call
|
||||||
else:
|
else:
|
||||||
ast_Call = lambda a,b,c: ast.Call(a, b, c, None, None)
|
ast_Call = lambda a, b, c: ast.Call(a, b, c, None, None)
|
||||||
|
|
||||||
|
|
||||||
class AssertionRewritingHook(object):
|
class AssertionRewritingHook(object):
|
||||||
|
|
|
@ -463,7 +463,7 @@ class DontReadFromInput:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def buffer(self):
|
def buffer(self):
|
||||||
if sys.version_info >= (3,0):
|
if sys.version_info >= (3, 0):
|
||||||
return self
|
return self
|
||||||
else:
|
else:
|
||||||
raise AttributeError('redirected stdin has no attribute buffer')
|
raise AttributeError('redirected stdin has no attribute buffer')
|
||||||
|
|
|
@ -392,7 +392,7 @@ class PytestPluginManager(PluginManager):
|
||||||
#
|
#
|
||||||
|
|
||||||
def consider_preparse(self, args):
|
def consider_preparse(self, args):
|
||||||
for opt1,opt2 in zip(args, args[1:]):
|
for opt1, opt2 in zip(args, args[1:]):
|
||||||
if opt1 == "-p":
|
if opt1 == "-p":
|
||||||
self.consider_pluginarg(opt2)
|
self.consider_pluginarg(opt2)
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ def reorder_items_atscope(items, ignore, argkeys_cache, scopenum):
|
||||||
items_before, items_same, items_other, newignore = \
|
items_before, items_same, items_other, newignore = \
|
||||||
slice_items(items, ignore, argkeys_cache[scopenum])
|
slice_items(items, ignore, argkeys_cache[scopenum])
|
||||||
items_before = reorder_items_atscope(
|
items_before = reorder_items_atscope(
|
||||||
items_before, ignore, argkeys_cache,scopenum + 1)
|
items_before, ignore, argkeys_cache, scopenum + 1)
|
||||||
if items_same is None:
|
if items_same is None:
|
||||||
# nothing to reorder in this scope
|
# nothing to reorder in this scope
|
||||||
assert items_other is None
|
assert items_other is None
|
||||||
|
|
|
@ -161,7 +161,7 @@ def pytest_report_header(config):
|
||||||
lines = []
|
lines = []
|
||||||
if config.option.debug or config.option.traceconfig:
|
if config.option.debug or config.option.traceconfig:
|
||||||
lines.append("using: pytest-%s pylib-%s" %
|
lines.append("using: pytest-%s pylib-%s" %
|
||||||
(pytest.__version__,py.__version__))
|
(pytest.__version__, py.__version__))
|
||||||
|
|
||||||
verinfo = getpluginversioninfo(config)
|
verinfo = getpluginversioninfo(config)
|
||||||
if verinfo:
|
if verinfo:
|
||||||
|
|
|
@ -76,9 +76,9 @@ def pytest_addoption(parser):
|
||||||
parser.addini("python_files", type="args",
|
parser.addini("python_files", type="args",
|
||||||
default=['test_*.py', '*_test.py'],
|
default=['test_*.py', '*_test.py'],
|
||||||
help="glob-style file patterns for Python test module discovery")
|
help="glob-style file patterns for Python test module discovery")
|
||||||
parser.addini("python_classes", type="args", default=["Test",],
|
parser.addini("python_classes", type="args", default=["Test", ],
|
||||||
help="prefixes or glob names for Python test class discovery")
|
help="prefixes or glob names for Python test class discovery")
|
||||||
parser.addini("python_functions", type="args", default=["test",],
|
parser.addini("python_functions", type="args", default=["test", ],
|
||||||
help="prefixes or glob names for Python test function and "
|
help="prefixes or glob names for Python test function and "
|
||||||
"method discovery")
|
"method discovery")
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ class PyCollector(PyobjMixin, main.Collector):
|
||||||
yield Function(name=subname, parent=self,
|
yield Function(name=subname, parent=self,
|
||||||
callspec=callspec, callobj=funcobj,
|
callspec=callspec, callobj=funcobj,
|
||||||
fixtureinfo=fixtureinfo,
|
fixtureinfo=fixtureinfo,
|
||||||
keywords={callspec.id:True},
|
keywords={callspec.id: True},
|
||||||
originalname=name,
|
originalname=name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ class CallSpec2(object):
|
||||||
|
|
||||||
def setmulti(self, valtypes, argnames, valset, id, keywords, scopenum,
|
def setmulti(self, valtypes, argnames, valset, id, keywords, scopenum,
|
||||||
param_index):
|
param_index):
|
||||||
for arg,val in zip(argnames, valset):
|
for arg, val in zip(argnames, valset):
|
||||||
self._checkargnotcontained(arg)
|
self._checkargnotcontained(arg)
|
||||||
valtype_for_arg = valtypes[arg]
|
valtype_for_arg = valtypes[arg]
|
||||||
getattr(self, valtype_for_arg)[arg] = val
|
getattr(self, valtype_for_arg)[arg] = val
|
||||||
|
|
|
@ -246,7 +246,7 @@ class BaseReport(object):
|
||||||
def pytest_runtest_makereport(item, call):
|
def pytest_runtest_makereport(item, call):
|
||||||
when = call.when
|
when = call.when
|
||||||
duration = call.stop - call.start
|
duration = call.stop - call.start
|
||||||
keywords = dict([(x,1) for x in item.keywords])
|
keywords = dict([(x, 1) for x in item.keywords])
|
||||||
excinfo = call.excinfo
|
excinfo = call.excinfo
|
||||||
sections = []
|
sections = []
|
||||||
if not call.excinfo:
|
if not call.excinfo:
|
||||||
|
|
|
@ -240,11 +240,11 @@ class TerminalReporter:
|
||||||
word, markup = word
|
word, markup = word
|
||||||
else:
|
else:
|
||||||
if rep.passed:
|
if rep.passed:
|
||||||
markup = {'green':True}
|
markup = {'green': True}
|
||||||
elif rep.failed:
|
elif rep.failed:
|
||||||
markup = {'red':True}
|
markup = {'red': True}
|
||||||
elif rep.skipped:
|
elif rep.skipped:
|
||||||
markup = {'yellow':True}
|
markup = {'yellow': True}
|
||||||
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)
|
||||||
|
|
|
@ -719,12 +719,12 @@ class TestDurations(object):
|
||||||
result = testdir.runpytest("--durations=0")
|
result = testdir.runpytest("--durations=0")
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
for x in "123":
|
for x in "123":
|
||||||
for y in 'call',: #'setup', 'call', 'teardown':
|
for y in 'call', : #'setup', 'call', 'teardown':
|
||||||
for line in result.stdout.lines:
|
for line in result.stdout.lines:
|
||||||
if ("test_%s" % x) in line and y in line:
|
if ("test_%s" % x) in line and y in line:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise AssertionError("not found %s %s" % (x,y))
|
raise AssertionError("not found %s %s" % (x, y))
|
||||||
|
|
||||||
def test_with_deselected(self, testdir):
|
def test_with_deselected(self, testdir):
|
||||||
testdir.makepyfile(self.source)
|
testdir.makepyfile(self.source)
|
||||||
|
|
|
@ -325,7 +325,7 @@ def test_excinfo_no_sourcecode():
|
||||||
except ValueError:
|
except ValueError:
|
||||||
excinfo = _pytest._code.ExceptionInfo()
|
excinfo = _pytest._code.ExceptionInfo()
|
||||||
s = str(excinfo.traceback[-1])
|
s = str(excinfo.traceback[-1])
|
||||||
if py.std.sys.version_info < (2,5):
|
if py.std.sys.version_info < (2, 5):
|
||||||
assert s == " File '<string>':1 in ?\n ???\n"
|
assert s == " File '<string>':1 in ?\n ???\n"
|
||||||
else:
|
else:
|
||||||
assert s == " File '<string>':1 in <module>\n ???\n"
|
assert s == " File '<string>':1 in <module>\n ???\n"
|
||||||
|
|
|
@ -109,7 +109,7 @@ def test_source_strip_multiline():
|
||||||
def test_syntaxerror_rerepresentation():
|
def test_syntaxerror_rerepresentation():
|
||||||
ex = pytest.raises(SyntaxError, _pytest._code.compile, 'xyz xyz')
|
ex = pytest.raises(SyntaxError, _pytest._code.compile, 'xyz xyz')
|
||||||
assert ex.value.lineno == 1
|
assert ex.value.lineno == 1
|
||||||
assert ex.value.offset in (4,7) # XXX pypy/jython versus cpython?
|
assert ex.value.offset in (4, 7) # XXX pypy/jython versus cpython?
|
||||||
assert ex.value.text.strip(), 'x x'
|
assert ex.value.text.strip(), 'x x'
|
||||||
|
|
||||||
def test_isparseable():
|
def test_isparseable():
|
||||||
|
@ -262,7 +262,7 @@ class TestSourceParsingAndCompiling(object):
|
||||||
def test_getstatementrange_out_of_bounds_py3(self):
|
def test_getstatementrange_out_of_bounds_py3(self):
|
||||||
source = Source("if xxx:\n from .collections import something")
|
source = Source("if xxx:\n from .collections import something")
|
||||||
r = source.getstatementrange(1)
|
r = source.getstatementrange(1)
|
||||||
assert r == (1,2)
|
assert r == (1, 2)
|
||||||
|
|
||||||
def test_getstatementrange_with_syntaxerror_issue7(self):
|
def test_getstatementrange_with_syntaxerror_issue7(self):
|
||||||
source = Source(":")
|
source = Source(":")
|
||||||
|
@ -524,9 +524,9 @@ def test_comments():
|
||||||
comment 4
|
comment 4
|
||||||
"""
|
"""
|
||||||
'''
|
'''
|
||||||
for line in range(2,6):
|
for line in range(2, 6):
|
||||||
assert str(getstatement(line, source)) == ' x = 1'
|
assert str(getstatement(line, source)) == ' x = 1'
|
||||||
for line in range(6,10):
|
for line in range(6, 10):
|
||||||
assert str(getstatement(line, source)) == ' assert False'
|
assert str(getstatement(line, source)) == ' assert False'
|
||||||
assert str(getstatement(10, source)) == '"""'
|
assert str(getstatement(10, source)) == '"""'
|
||||||
|
|
||||||
|
@ -535,7 +535,7 @@ def test_comment_in_statement():
|
||||||
# comment 1
|
# comment 1
|
||||||
bar=2)
|
bar=2)
|
||||||
'''
|
'''
|
||||||
for line in range(1,3):
|
for line in range(1, 3):
|
||||||
assert str(getstatement(line, source)) == \
|
assert str(getstatement(line, source)) == \
|
||||||
'test(foo=1,\n # comment 1\n bar=2)'
|
'test(foo=1,\n # comment 1\n bar=2)'
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ class TestApprox(object):
|
||||||
|
|
||||||
def test_expecting_sequence_wrong_len(self):
|
def test_expecting_sequence_wrong_len(self):
|
||||||
assert [1, 2] != approx([1])
|
assert [1, 2] != approx([1])
|
||||||
assert [1, 2] != approx([1,2,3])
|
assert [1, 2] != approx([1, 2, 3])
|
||||||
|
|
||||||
def test_complex(self):
|
def test_complex(self):
|
||||||
within_1e6 = [
|
within_1e6 = [
|
||||||
|
|
|
@ -421,7 +421,7 @@ class TestFunction(object):
|
||||||
f1 = pytest.Function(name="name", parent=session, config=config,
|
f1 = pytest.Function(name="name", parent=session, config=config,
|
||||||
args=(1,), callobj=func1)
|
args=(1,), callobj=func1)
|
||||||
assert f1 == f1
|
assert f1 == f1
|
||||||
f2 = pytest.Function(name="name",config=config,
|
f2 = pytest.Function(name="name", config=config,
|
||||||
callobj=func2, parent=session)
|
callobj=func2, parent=session)
|
||||||
assert f1 != f2
|
assert f1 != f2
|
||||||
|
|
||||||
|
@ -733,11 +733,11 @@ class TestSorting(object):
|
||||||
assert not (fn1 == fn3)
|
assert not (fn1 == fn3)
|
||||||
assert fn1 != fn3
|
assert fn1 != fn3
|
||||||
|
|
||||||
for fn in fn1,fn2,fn3:
|
for fn in fn1, fn2, fn3:
|
||||||
assert fn != 3
|
assert fn != 3
|
||||||
assert fn != modcol
|
assert fn != modcol
|
||||||
assert fn != [1,2,3]
|
assert fn != [1, 2, 3]
|
||||||
assert [1,2,3] != fn
|
assert [1, 2, 3] != fn
|
||||||
assert modcol != fn
|
assert modcol != fn
|
||||||
|
|
||||||
def test_allow_sane_sorting_for_decorators(self, testdir):
|
def test_allow_sane_sorting_for_decorators(self, testdir):
|
||||||
|
|
|
@ -25,7 +25,7 @@ def test_getfuncargnames():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
assert fixtures.getfuncargnames(A().f) == ('arg1',)
|
assert fixtures.getfuncargnames(A().f) == ('arg1',)
|
||||||
if sys.version_info < (3,0):
|
if sys.version_info < (3, 0):
|
||||||
assert fixtures.getfuncargnames(A.f) == ('arg1',)
|
assert fixtures.getfuncargnames(A.f) == ('arg1',)
|
||||||
|
|
||||||
class TestFillFixtures(object):
|
class TestFillFixtures(object):
|
||||||
|
@ -817,7 +817,7 @@ class TestRequestBasic(object):
|
||||||
|
|
||||||
class TestRequestMarking(object):
|
class TestRequestMarking(object):
|
||||||
def test_applymarker(self, testdir):
|
def test_applymarker(self, testdir):
|
||||||
item1,item2 = testdir.getitems("""
|
item1, item2 = testdir.getitems("""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -1297,7 +1297,7 @@ class TestFixtureUsages(object):
|
||||||
reprec = testdir.inline_run("-v")
|
reprec = testdir.inline_run("-v")
|
||||||
reprec.assertoutcome(passed=4)
|
reprec.assertoutcome(passed=4)
|
||||||
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l
|
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l
|
||||||
assert l == [1,2, 10,20]
|
assert l == [1, 2, 10, 20]
|
||||||
|
|
||||||
|
|
||||||
class TestFixtureManagerParseFactories(object):
|
class TestFixtureManagerParseFactories(object):
|
||||||
|
@ -1706,7 +1706,7 @@ class TestAutouseManagement(object):
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
confcut = "--confcutdir={0}".format(testdir.tmpdir)
|
confcut = "--confcutdir={0}".format(testdir.tmpdir)
|
||||||
reprec = testdir.inline_run("-v","-s", confcut)
|
reprec = testdir.inline_run("-v", "-s", confcut)
|
||||||
reprec.assertoutcome(passed=8)
|
reprec.assertoutcome(passed=8)
|
||||||
config = reprec.getcalls("pytest_unconfigure")[0].config
|
config = reprec.getcalls("pytest_unconfigure")[0].config
|
||||||
l = config.pluginmanager._getconftestmodules(p)[0].l
|
l = config.pluginmanager._getconftestmodules(p)[0].l
|
||||||
|
@ -1776,8 +1776,8 @@ class TestAutouseManagement(object):
|
||||||
reprec.assertoutcome(passed=1)
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
@pytest.mark.issue226
|
@pytest.mark.issue226
|
||||||
@pytest.mark.parametrize("param1", ["", "params=[1]"], ids=["p00","p01"])
|
@pytest.mark.parametrize("param1", ["", "params=[1]"], ids=["p00", "p01"])
|
||||||
@pytest.mark.parametrize("param2", ["", "params=[1]"], ids=["p10","p11"])
|
@pytest.mark.parametrize("param2", ["", "params=[1]"], ids=["p10", "p11"])
|
||||||
def test_ordering_dependencies_torndown_first(self, testdir, param1, param2):
|
def test_ordering_dependencies_torndown_first(self, testdir, param1, param2):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -2108,7 +2108,7 @@ class TestFixtureMarker(object):
|
||||||
reprec = testdir.inline_run("-v")
|
reprec = testdir.inline_run("-v")
|
||||||
reprec.assertoutcome(passed=4)
|
reprec.assertoutcome(passed=4)
|
||||||
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l
|
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l
|
||||||
assert l == [1,1,2,2]
|
assert l == [1, 1, 2, 2]
|
||||||
|
|
||||||
def test_module_parametrized_ordering(self, testdir):
|
def test_module_parametrized_ordering(self, testdir):
|
||||||
testdir.makeconftest("""
|
testdir.makeconftest("""
|
||||||
|
@ -2351,7 +2351,7 @@ class TestFixtureMarker(object):
|
||||||
""")
|
""")
|
||||||
reprec = testdir.inline_run("-s")
|
reprec = testdir.inline_run("-s")
|
||||||
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l
|
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l
|
||||||
assert l == [1,2]
|
assert l == [1, 2]
|
||||||
|
|
||||||
def test_parametrize_separated_lifecycle(self, testdir):
|
def test_parametrize_separated_lifecycle(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
|
@ -2544,7 +2544,7 @@ class TestFixtureMarker(object):
|
||||||
|
|
||||||
|
|
||||||
class TestRequestScopeAccess(object):
|
class TestRequestScopeAccess(object):
|
||||||
pytestmark = pytest.mark.parametrize(("scope", "ok", "error"),[
|
pytestmark = pytest.mark.parametrize(("scope", "ok", "error"), [
|
||||||
["session", "", "fspath class function module"],
|
["session", "", "fspath class function module"],
|
||||||
["module", "module fspath", "cls function"],
|
["module", "module fspath", "cls function"],
|
||||||
["class", "module fspath cls", "function"],
|
["class", "module fspath cls", "function"],
|
||||||
|
|
|
@ -96,12 +96,12 @@ class TestMetafunc(object):
|
||||||
def test_parametrize_error(self):
|
def test_parametrize_error(self):
|
||||||
def func(x, y): pass
|
def func(x, y): pass
|
||||||
metafunc = self.Metafunc(func)
|
metafunc = self.Metafunc(func)
|
||||||
metafunc.parametrize("x", [1,2])
|
metafunc.parametrize("x", [1, 2])
|
||||||
pytest.raises(ValueError, lambda: metafunc.parametrize("x", [5,6]))
|
pytest.raises(ValueError, lambda: metafunc.parametrize("x", [5, 6]))
|
||||||
pytest.raises(ValueError, lambda: metafunc.parametrize("x", [5,6]))
|
pytest.raises(ValueError, lambda: metafunc.parametrize("x", [5, 6]))
|
||||||
metafunc.parametrize("y", [1,2])
|
metafunc.parametrize("y", [1, 2])
|
||||||
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5,6]))
|
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6]))
|
||||||
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5,6]))
|
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6]))
|
||||||
|
|
||||||
def test_parametrize_bad_scope(self, testdir):
|
def test_parametrize_bad_scope(self, testdir):
|
||||||
def func(x): pass
|
def func(x): pass
|
||||||
|
@ -115,7 +115,7 @@ class TestMetafunc(object):
|
||||||
def func(x, y): pass
|
def func(x, y): pass
|
||||||
metafunc = self.Metafunc(func)
|
metafunc = self.Metafunc(func)
|
||||||
|
|
||||||
metafunc.parametrize("x", [1,2], ids=['basic', 'advanced'])
|
metafunc.parametrize("x", [1, 2], ids=['basic', 'advanced'])
|
||||||
metafunc.parametrize("y", ["abc", "def"])
|
metafunc.parametrize("y", ["abc", "def"])
|
||||||
ids = [x.id for x in metafunc._calls]
|
ids = [x.id for x in metafunc._calls]
|
||||||
assert ids == ["basic-abc", "basic-def", "advanced-abc", "advanced-def"]
|
assert ids == ["basic-abc", "basic-def", "advanced-abc", "advanced-def"]
|
||||||
|
@ -133,11 +133,11 @@ class TestMetafunc(object):
|
||||||
metafunc = self.Metafunc(func)
|
metafunc = self.Metafunc(func)
|
||||||
|
|
||||||
pytest.raises(ValueError, lambda:
|
pytest.raises(ValueError, lambda:
|
||||||
metafunc.parametrize("x", [1,2], ids=['basic']))
|
metafunc.parametrize("x", [1, 2], ids=['basic']))
|
||||||
|
|
||||||
pytest.raises(ValueError, lambda:
|
pytest.raises(ValueError, lambda:
|
||||||
metafunc.parametrize(("x","y"), [("abc", "def"),
|
metafunc.parametrize(("x", "y"), [("abc", "def"),
|
||||||
("ghi", "jkl")], ids=["one"]))
|
("ghi", "jkl")], ids=["one"]))
|
||||||
|
|
||||||
@pytest.mark.issue510
|
@pytest.mark.issue510
|
||||||
def test_parametrize_empty_list(self):
|
def test_parametrize_empty_list(self):
|
||||||
|
@ -371,7 +371,7 @@ class TestMetafunc(object):
|
||||||
|
|
||||||
def test_idmaker_with_ids_unique_names(self):
|
def test_idmaker_with_ids_unique_names(self):
|
||||||
from _pytest.python import idmaker
|
from _pytest.python import idmaker
|
||||||
result = idmaker(("a"), map(pytest.param, [1,2,3,4,5]),
|
result = idmaker(("a"), map(pytest.param, [1, 2, 3, 4, 5]),
|
||||||
ids=["a", "a", "b", "c", "b"])
|
ids=["a", "a", "b", "c", "b"])
|
||||||
assert result == ["a0", "a1", "b0", "c", "b1"]
|
assert result == ["a0", "a1", "b0", "c", "b1"]
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ class TestMetafunc(object):
|
||||||
def func(x, y): pass
|
def func(x, y): pass
|
||||||
metafunc = self.Metafunc(func)
|
metafunc = self.Metafunc(func)
|
||||||
metafunc.addcall({'x': 1})
|
metafunc.addcall({'x': 1})
|
||||||
metafunc.parametrize('y', [2,3])
|
metafunc.parametrize('y', [2, 3])
|
||||||
assert len(metafunc._calls) == 2
|
assert len(metafunc._calls) == 2
|
||||||
assert metafunc._calls[0].funcargs == {'x': 1, 'y': 2}
|
assert metafunc._calls[0].funcargs == {'x': 1, 'y': 2}
|
||||||
assert metafunc._calls[1].funcargs == {'x': 1, 'y': 3}
|
assert metafunc._calls[1].funcargs == {'x': 1, 'y': 3}
|
||||||
|
@ -391,12 +391,12 @@ class TestMetafunc(object):
|
||||||
def func(x, y): pass
|
def func(x, y): pass
|
||||||
metafunc = self.Metafunc(func)
|
metafunc = self.Metafunc(func)
|
||||||
metafunc.parametrize('x', [1], indirect=True)
|
metafunc.parametrize('x', [1], indirect=True)
|
||||||
metafunc.parametrize('y', [2,3], indirect=True)
|
metafunc.parametrize('y', [2, 3], indirect=True)
|
||||||
assert len(metafunc._calls) == 2
|
assert len(metafunc._calls) == 2
|
||||||
assert metafunc._calls[0].funcargs == {}
|
assert metafunc._calls[0].funcargs == {}
|
||||||
assert metafunc._calls[1].funcargs == {}
|
assert metafunc._calls[1].funcargs == {}
|
||||||
assert metafunc._calls[0].params == dict(x=1,y=2)
|
assert metafunc._calls[0].params == dict(x=1, y=2)
|
||||||
assert metafunc._calls[1].params == dict(x=1,y=3)
|
assert metafunc._calls[1].params == dict(x=1, y=3)
|
||||||
|
|
||||||
@pytest.mark.issue714
|
@pytest.mark.issue714
|
||||||
def test_parametrize_indirect_list(self):
|
def test_parametrize_indirect_list(self):
|
||||||
|
@ -554,12 +554,12 @@ class TestMetafunc(object):
|
||||||
metafunc = self.Metafunc(func)
|
metafunc = self.Metafunc(func)
|
||||||
metafunc.addcall(param="123")
|
metafunc.addcall(param="123")
|
||||||
metafunc.parametrize('x', [1], indirect=True)
|
metafunc.parametrize('x', [1], indirect=True)
|
||||||
metafunc.parametrize('y', [2,3], indirect=True)
|
metafunc.parametrize('y', [2, 3], indirect=True)
|
||||||
assert len(metafunc._calls) == 2
|
assert len(metafunc._calls) == 2
|
||||||
assert metafunc._calls[0].funcargs == {}
|
assert metafunc._calls[0].funcargs == {}
|
||||||
assert metafunc._calls[1].funcargs == {}
|
assert metafunc._calls[1].funcargs == {}
|
||||||
assert metafunc._calls[0].params == dict(x=1,y=2)
|
assert metafunc._calls[0].params == dict(x=1, y=2)
|
||||||
assert metafunc._calls[1].params == dict(x=1,y=3)
|
assert metafunc._calls[1].params == dict(x=1, y=3)
|
||||||
|
|
||||||
def test_parametrize_functional(self, testdir):
|
def test_parametrize_functional(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
|
@ -584,7 +584,7 @@ class TestMetafunc(object):
|
||||||
|
|
||||||
def test_parametrize_onearg(self):
|
def test_parametrize_onearg(self):
|
||||||
metafunc = self.Metafunc(lambda x: None)
|
metafunc = self.Metafunc(lambda x: None)
|
||||||
metafunc.parametrize("x", [1,2])
|
metafunc.parametrize("x", [1, 2])
|
||||||
assert len(metafunc._calls) == 2
|
assert len(metafunc._calls) == 2
|
||||||
assert metafunc._calls[0].funcargs == dict(x=1)
|
assert metafunc._calls[0].funcargs == dict(x=1)
|
||||||
assert metafunc._calls[0].id == "1"
|
assert metafunc._calls[0].id == "1"
|
||||||
|
@ -593,15 +593,15 @@ class TestMetafunc(object):
|
||||||
|
|
||||||
def test_parametrize_onearg_indirect(self):
|
def test_parametrize_onearg_indirect(self):
|
||||||
metafunc = self.Metafunc(lambda x: None)
|
metafunc = self.Metafunc(lambda x: None)
|
||||||
metafunc.parametrize("x", [1,2], indirect=True)
|
metafunc.parametrize("x", [1, 2], indirect=True)
|
||||||
assert metafunc._calls[0].params == dict(x=1)
|
assert metafunc._calls[0].params == dict(x=1)
|
||||||
assert metafunc._calls[0].id == "1"
|
assert metafunc._calls[0].id == "1"
|
||||||
assert metafunc._calls[1].params == dict(x=2)
|
assert metafunc._calls[1].params == dict(x=2)
|
||||||
assert metafunc._calls[1].id == "2"
|
assert metafunc._calls[1].id == "2"
|
||||||
|
|
||||||
def test_parametrize_twoargs(self):
|
def test_parametrize_twoargs(self):
|
||||||
metafunc = self.Metafunc(lambda x,y: None)
|
metafunc = self.Metafunc(lambda x, y: None)
|
||||||
metafunc.parametrize(("x", "y"), [(1,2), (3,4)])
|
metafunc.parametrize(("x", "y"), [(1, 2), (3, 4)])
|
||||||
assert len(metafunc._calls) == 2
|
assert len(metafunc._calls) == 2
|
||||||
assert metafunc._calls[0].funcargs == dict(x=1, y=2)
|
assert metafunc._calls[0].funcargs == dict(x=1, y=2)
|
||||||
assert metafunc._calls[0].id == "1-2"
|
assert metafunc._calls[0].id == "1-2"
|
||||||
|
|
|
@ -19,8 +19,8 @@ def equal_with_bash(prefix, ffc, fc, out=None):
|
||||||
# this gives an IOError at the end of testrun
|
# this gives an IOError at the end of testrun
|
||||||
def _wrapcall(*args, **kargs):
|
def _wrapcall(*args, **kargs):
|
||||||
try:
|
try:
|
||||||
if py.std.sys.version_info > (2,7):
|
if py.std.sys.version_info > (2, 7):
|
||||||
return py.std.subprocess.check_output(*args,**kargs).decode().splitlines()
|
return py.std.subprocess.check_output(*args, **kargs).decode().splitlines()
|
||||||
if 'stdout' in kargs:
|
if 'stdout' in kargs:
|
||||||
raise ValueError('stdout argument not allowed, it will be overridden.')
|
raise ValueError('stdout argument not allowed, it will be overridden.')
|
||||||
process = py.std.subprocess.Popen(
|
process = py.std.subprocess.Popen(
|
||||||
|
@ -38,7 +38,7 @@ def _wrapcall(*args, **kargs):
|
||||||
|
|
||||||
class FilesCompleter(object):
|
class FilesCompleter(object):
|
||||||
'File completer class, optionally takes a list of allowed extensions'
|
'File completer class, optionally takes a list of allowed extensions'
|
||||||
def __init__(self,allowednames=(),directories=True):
|
def __init__(self, allowednames=(), directories=True):
|
||||||
# Fix if someone passes in a string instead of a list
|
# Fix if someone passes in a string instead of a list
|
||||||
if type(allowednames) is str:
|
if type(allowednames) is str:
|
||||||
allowednames = [allowednames]
|
allowednames = [allowednames]
|
||||||
|
@ -50,12 +50,12 @@ class FilesCompleter(object):
|
||||||
completion = []
|
completion = []
|
||||||
if self.allowednames:
|
if self.allowednames:
|
||||||
if self.directories:
|
if self.directories:
|
||||||
files = _wrapcall(['bash','-c',
|
files = _wrapcall(['bash', '-c',
|
||||||
"compgen -A directory -- '{p}'".format(p=prefix)])
|
"compgen -A directory -- '{p}'".format(p=prefix)])
|
||||||
completion += [f + '/' for f in files]
|
completion += [f + '/' for f in files]
|
||||||
for x in self.allowednames:
|
for x in self.allowednames:
|
||||||
completion += _wrapcall(['bash', '-c',
|
completion += _wrapcall(['bash', '-c',
|
||||||
"compgen -A file -X '!*.{0}' -- '{p}'".format(x,p=prefix)])
|
"compgen -A file -X '!*.{0}' -- '{p}'".format(x, p=prefix)])
|
||||||
else:
|
else:
|
||||||
completion += _wrapcall(['bash', '-c',
|
completion += _wrapcall(['bash', '-c',
|
||||||
"compgen -A file -- '{p}'".format(p=prefix)])
|
"compgen -A file -- '{p}'".format(p=prefix)])
|
||||||
|
|
|
@ -437,9 +437,9 @@ class TestAssert_reprcompare(object):
|
||||||
assert len(expl) > 1
|
assert len(expl) > 1
|
||||||
|
|
||||||
def test_list_tuples(self):
|
def test_list_tuples(self):
|
||||||
expl = callequal([], [(1,2)])
|
expl = callequal([], [(1, 2)])
|
||||||
assert len(expl) > 1
|
assert len(expl) > 1
|
||||||
expl = callequal([(1,2)], [])
|
expl = callequal([(1, 2)], [])
|
||||||
assert len(expl) > 1
|
assert len(expl) > 1
|
||||||
|
|
||||||
def test_list_bad_repr(self):
|
def test_list_bad_repr(self):
|
||||||
|
|
|
@ -638,7 +638,7 @@ def test_rewritten():
|
||||||
testdir.tmpdir.join("test_newlines.py").write(b, "wb")
|
testdir.tmpdir.join("test_newlines.py").write(b, "wb")
|
||||||
assert testdir.runpytest().ret == 0
|
assert testdir.runpytest().ret == 0
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.version_info < (3,3),
|
@pytest.mark.skipif(sys.version_info < (3, 3),
|
||||||
reason='packages without __init__.py not supported on python 2')
|
reason='packages without __init__.py not supported on python 2')
|
||||||
def test_package_without__init__py(self, testdir):
|
def test_package_without__init__py(self, testdir):
|
||||||
pkg = testdir.mkdir('a_package_without_init_py')
|
pkg = testdir.mkdir('a_package_without_init_py')
|
||||||
|
|
|
@ -112,7 +112,7 @@ class TestCaptureManager(object):
|
||||||
|
|
||||||
@pytest.mark.parametrize("method", ['fd', 'sys'])
|
@pytest.mark.parametrize("method", ['fd', 'sys'])
|
||||||
def test_capturing_unicode(testdir, method):
|
def test_capturing_unicode(testdir, method):
|
||||||
if hasattr(sys, "pypy_version_info") and sys.pypy_version_info < (2,2):
|
if hasattr(sys, "pypy_version_info") and sys.pypy_version_info < (2, 2):
|
||||||
pytest.xfail("does not work on pypy < 2.2")
|
pytest.xfail("does not work on pypy < 2.2")
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
obj = "'b\u00f6y'"
|
obj = "'b\u00f6y'"
|
||||||
|
|
|
@ -42,11 +42,11 @@ class TestCollector(object):
|
||||||
assert not (fn1 == fn3)
|
assert not (fn1 == fn3)
|
||||||
assert fn1 != fn3
|
assert fn1 != fn3
|
||||||
|
|
||||||
for fn in fn1,fn2,fn3:
|
for fn in fn1, fn2, fn3:
|
||||||
assert fn != 3
|
assert fn != 3
|
||||||
assert fn != modcol
|
assert fn != modcol
|
||||||
assert fn != [1,2,3]
|
assert fn != [1, 2, 3]
|
||||||
assert [1,2,3] != fn
|
assert [1, 2, 3] != fn
|
||||||
assert modcol != fn
|
assert modcol != fn
|
||||||
|
|
||||||
def test_getparent(self, testdir):
|
def test_getparent(self, testdir):
|
||||||
|
|
|
@ -666,7 +666,7 @@ class TestRootdir(object):
|
||||||
rootdir, inifile, inicfg = determine_setup(None, args)
|
rootdir, inifile, inicfg = determine_setup(None, args)
|
||||||
assert rootdir == tmpdir
|
assert rootdir == tmpdir
|
||||||
assert inifile == inifile
|
assert inifile == inifile
|
||||||
rootdir, inifile, inicfg = determine_setup(None, [b,a])
|
rootdir, inifile, inicfg = determine_setup(None, [b, a])
|
||||||
assert rootdir == tmpdir
|
assert rootdir == tmpdir
|
||||||
assert inifile == inifile
|
assert inifile == inifile
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ class TestConftestVisibility(object):
|
||||||
])
|
])
|
||||||
@pytest.mark.issue616
|
@pytest.mark.issue616
|
||||||
def test_parsefactories_relative_node_ids(
|
def test_parsefactories_relative_node_ids(
|
||||||
self, testdir, chdir,testarg, expect_ntests_passed):
|
self, testdir, chdir, testarg, expect_ntests_passed):
|
||||||
dirs = self._setup_tree(testdir)
|
dirs = self._setup_tree(testdir)
|
||||||
print("pytest run in cwd: %s" % (
|
print("pytest run in cwd: %s" % (
|
||||||
dirs[chdir].relto(testdir.tmpdir)))
|
dirs[chdir].relto(testdir.tmpdir)))
|
||||||
|
|
|
@ -8,7 +8,7 @@ from _pytest.mark import MarkGenerator as Mark, ParameterSet
|
||||||
class TestMark(object):
|
class TestMark(object):
|
||||||
def test_markinfo_repr(self):
|
def test_markinfo_repr(self):
|
||||||
from _pytest.mark import MarkInfo, Mark
|
from _pytest.mark import MarkInfo, Mark
|
||||||
m = MarkInfo(Mark("hello", (1,2), {}))
|
m = MarkInfo(Mark("hello", (1, 2), {}))
|
||||||
repr(m)
|
repr(m)
|
||||||
|
|
||||||
@pytest.mark.parametrize('attr', ['mark', 'param'])
|
@pytest.mark.parametrize('attr', ['mark', 'param'])
|
||||||
|
|
|
@ -284,7 +284,7 @@ def test_argcomplete(testdir, monkeypatch):
|
||||||
# to handle a keyword argument env that replaces os.environ in popen or
|
# to handle a keyword argument env that replaces os.environ in popen or
|
||||||
# extends the copy, advantage: could not forget to restore
|
# extends the copy, advantage: could not forget to restore
|
||||||
monkeypatch.setenv('_ARGCOMPLETE', "1")
|
monkeypatch.setenv('_ARGCOMPLETE', "1")
|
||||||
monkeypatch.setenv('_ARGCOMPLETE_IFS',"\x0b")
|
monkeypatch.setenv('_ARGCOMPLETE_IFS', "\x0b")
|
||||||
monkeypatch.setenv('COMP_WORDBREAKS', ' \\t\\n"\\\'><=;|&(:')
|
monkeypatch.setenv('COMP_WORDBREAKS', ' \\t\\n"\\\'><=;|&(:')
|
||||||
|
|
||||||
arg = '--fu'
|
arg = '--fu'
|
||||||
|
@ -297,12 +297,12 @@ def test_argcomplete(testdir, monkeypatch):
|
||||||
elif not result.stdout.str():
|
elif not result.stdout.str():
|
||||||
pytest.skip("bash provided no output, argcomplete not available?")
|
pytest.skip("bash provided no output, argcomplete not available?")
|
||||||
else:
|
else:
|
||||||
if py.std.sys.version_info < (2,7):
|
if py.std.sys.version_info < (2, 7):
|
||||||
result.stdout.lines = result.stdout.lines[0].split('\x0b')
|
result.stdout.lines = result.stdout.lines[0].split('\x0b')
|
||||||
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
|
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
|
||||||
else:
|
else:
|
||||||
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
|
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
|
||||||
if py.std.sys.version_info < (2,7):
|
if py.std.sys.version_info < (2, 7):
|
||||||
return
|
return
|
||||||
os.mkdir('test_argcomplete.d')
|
os.mkdir('test_argcomplete.d')
|
||||||
arg = 'test_argc'
|
arg = 'test_argc'
|
||||||
|
|
|
@ -26,7 +26,7 @@ class TestPasteCapture(object):
|
||||||
assert len(pastebinlist) == 1
|
assert len(pastebinlist) == 1
|
||||||
s = pastebinlist[0]
|
s = pastebinlist[0]
|
||||||
assert s.find("def test_fail") != -1
|
assert s.find("def test_fail") != -1
|
||||||
assert reprec.countoutcomes() == [1,1,1]
|
assert reprec.countoutcomes() == [1, 1, 1]
|
||||||
|
|
||||||
def test_all(self, testdir, pastebinlist):
|
def test_all(self, testdir, pastebinlist):
|
||||||
from _pytest.pytester import LineMatcher
|
from _pytest.pytester import LineMatcher
|
||||||
|
@ -40,7 +40,7 @@ class TestPasteCapture(object):
|
||||||
pytest.skip("")
|
pytest.skip("")
|
||||||
""")
|
""")
|
||||||
reprec = testdir.inline_run(testpath, "--pastebin=all", '-v')
|
reprec = testdir.inline_run(testpath, "--pastebin=all", '-v')
|
||||||
assert reprec.countoutcomes() == [1,1,1]
|
assert reprec.countoutcomes() == [1, 1, 1]
|
||||||
assert len(pastebinlist) == 1
|
assert len(pastebinlist) == 1
|
||||||
contents = pastebinlist[0].decode('utf-8')
|
contents = pastebinlist[0].decode('utf-8')
|
||||||
matcher = LineMatcher(contents.splitlines())
|
matcher = LineMatcher(contents.splitlines())
|
||||||
|
|
|
@ -227,7 +227,7 @@ class BaseFunctionalTests(object):
|
||||||
assert reps[2].when == "teardown"
|
assert reps[2].when == "teardown"
|
||||||
assert reps[2].failed
|
assert reps[2].failed
|
||||||
assert len(reps) == 6
|
assert len(reps) == 6
|
||||||
for i in range(3,5):
|
for i in range(3, 5):
|
||||||
assert reps[i].nodeid.endswith("test_func")
|
assert reps[i].nodeid.endswith("test_func")
|
||||||
assert reps[i].passed
|
assert reps[i].passed
|
||||||
assert reps[5].when == "teardown"
|
assert reps[5].when == "teardown"
|
||||||
|
|
|
@ -872,7 +872,7 @@ def test_terminal_summary_warnings_are_displayed(testdir):
|
||||||
("yellow", "1 passed, 1 warnings", {"warnings": (1,),
|
("yellow", "1 passed, 1 warnings", {"warnings": (1,),
|
||||||
"passed": (1,)}),
|
"passed": (1,)}),
|
||||||
|
|
||||||
("green", "5 passed", {"passed": (1,2,3,4,5)}),
|
("green", "5 passed", {"passed": (1, 2, 3, 4, 5)}),
|
||||||
|
|
||||||
|
|
||||||
# "Boring" statuses. These have no effect on the color of the summary
|
# "Boring" statuses. These have no effect on the color of the summary
|
||||||
|
@ -901,13 +901,13 @@ def test_terminal_summary_warnings_are_displayed(testdir):
|
||||||
|
|
||||||
# A couple more complex combinations
|
# A couple more complex combinations
|
||||||
("red", "1 failed, 2 passed, 3 xfailed",
|
("red", "1 failed, 2 passed, 3 xfailed",
|
||||||
{"passed": (1,2), "failed": (1,), "xfailed": (1,2,3)}),
|
{"passed": (1, 2), "failed": (1,), "xfailed": (1, 2, 3)}),
|
||||||
|
|
||||||
("green", "1 passed, 2 skipped, 3 deselected, 2 xfailed",
|
("green", "1 passed, 2 skipped, 3 deselected, 2 xfailed",
|
||||||
{"passed": (1,),
|
{"passed": (1,),
|
||||||
"skipped": (1,2),
|
"skipped": (1, 2),
|
||||||
"deselected": (1,2,3),
|
"deselected": (1, 2, 3),
|
||||||
"xfailed": (1,2)}),
|
"xfailed": (1, 2)}),
|
||||||
])
|
])
|
||||||
def test_summary_stats(exp_line, exp_color, stats_arg):
|
def test_summary_stats(exp_line, exp_color, stats_arg):
|
||||||
print("Based on stats: %s" % stats_arg)
|
print("Based on stats: %s" % stats_arg)
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -196,6 +196,6 @@ filterwarnings =
|
||||||
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
|
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = E231,E241,E251,E261,E262,E265,E271,E272,E293,E301,E302,E303,E401,E402,E501,E701,E702,E704,E712,E731
|
ignore = E241,E251,E261,E262,E265,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
|
||||||
|
|
Loading…
Reference in New Issue