Fixed E704 flake8 errors

multiple statements on one line (def)
This commit is contained in:
Andras Tim 2017-07-17 01:25:10 +02:00
parent bf259d3c93
commit 5ae59279f4
5 changed files with 71 additions and 36 deletions

View File

@ -100,5 +100,6 @@ if os.environ.get('_ARGCOMPLETE'):
def try_argcomplete(parser):
argcomplete.autocomplete(parser)
else:
def try_argcomplete(parser): pass
def try_argcomplete(parser):
pass
filescompleter = None

View File

@ -9,16 +9,20 @@ from _pytest import fixtures
def test_getfuncargnames():
def f(): pass
def f():
pass
assert not fixtures.getfuncargnames(f)
def g(arg): pass
def g(arg):
pass
assert fixtures.getfuncargnames(g) == ('arg',)
def h(arg1, arg2="hello"): pass
def h(arg1, arg2="hello"):
pass
assert fixtures.getfuncargnames(h) == ('arg1',)
def h(arg1, arg2, arg3="hello"): pass
def h(arg1, arg2, arg3="hello"):
pass
assert fixtures.getfuncargnames(h) == ('arg1', 'arg2')
class A(object):
@ -552,7 +556,8 @@ class TestRequestBasic(object):
else:
# see #1830 for a cleaner way to accomplish this
@contextlib.contextmanager
def expecting_no_warning(): yield
def expecting_no_warning():
yield
warning_expectation = expecting_no_warning()

View File

@ -29,13 +29,15 @@ class TestMetafunc(object):
return python.Metafunc(func, fixtureinfo, None)
def test_no_funcargs(self, testdir):
def function(): pass
def function():
pass
metafunc = self.Metafunc(function)
assert not metafunc.fixturenames
repr(metafunc._calls)
def test_function_basic(self):
def func(arg1, arg2="qwe"): pass
def func(arg1, arg2="qwe"):
pass
metafunc = self.Metafunc(func)
assert len(metafunc.fixturenames) == 1
assert 'arg1' in metafunc.fixturenames
@ -43,7 +45,8 @@ class TestMetafunc(object):
assert metafunc.cls is None
def test_addcall_no_args(self):
def func(arg1): pass
def func(arg1):
pass
metafunc = self.Metafunc(func)
metafunc.addcall()
assert len(metafunc._calls) == 1
@ -52,7 +55,8 @@ class TestMetafunc(object):
assert not hasattr(call, 'param')
def test_addcall_id(self):
def func(arg1): pass
def func(arg1):
pass
metafunc = self.Metafunc(func)
pytest.raises(ValueError, "metafunc.addcall(id=None)")
@ -65,7 +69,8 @@ class TestMetafunc(object):
assert metafunc._calls[1].id == "2"
def test_addcall_param(self):
def func(arg1): pass
def func(arg1):
pass
metafunc = self.Metafunc(func)
class obj(object):
@ -80,7 +85,8 @@ class TestMetafunc(object):
assert metafunc._calls[2].getparam("arg1") == 1
def test_addcall_funcargs(self):
def func(x): pass
def func(x):
pass
metafunc = self.Metafunc(func)
@ -96,7 +102,8 @@ class TestMetafunc(object):
assert not hasattr(metafunc._calls[1], 'param')
def test_parametrize_error(self):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
metafunc.parametrize("x", [1, 2])
pytest.raises(ValueError, lambda: metafunc.parametrize("x", [5, 6]))
@ -106,7 +113,8 @@ class TestMetafunc(object):
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6]))
def test_parametrize_bad_scope(self, testdir):
def func(x): pass
def func(x):
pass
metafunc = self.Metafunc(func)
try:
metafunc.parametrize("x", [1], scope='doggy')
@ -114,7 +122,8 @@ class TestMetafunc(object):
assert "has an unsupported scope value 'doggy'" in str(ve)
def test_parametrize_and_id(self):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
metafunc.parametrize("x", [1, 2], ids=['basic', 'advanced'])
@ -124,14 +133,16 @@ class TestMetafunc(object):
def test_parametrize_and_id_unicode(self):
"""Allow unicode strings for "ids" parameter in Python 2 (##1905)"""
def func(x): pass
def func(x):
pass
metafunc = self.Metafunc(func)
metafunc.parametrize("x", [1, 2], ids=[u'basic', u'advanced'])
ids = [x.id for x in metafunc._calls]
assert ids == [u"basic", u"advanced"]
def test_parametrize_with_wrong_number_of_ids(self, testdir):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
pytest.raises(ValueError, lambda:
@ -143,13 +154,15 @@ class TestMetafunc(object):
@pytest.mark.issue510
def test_parametrize_empty_list(self):
def func(y): pass
def func(y):
pass
metafunc = self.Metafunc(func)
metafunc.parametrize("y", [])
assert 'skip' in metafunc._calls[0].keywords
def test_parametrize_with_userobjects(self):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
class A(object):
@ -393,7 +406,8 @@ class TestMetafunc(object):
assert result == ["a0", "a1", "b0", "c", "b1"]
def test_addcall_and_parametrize(self):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
metafunc.addcall({'x': 1})
metafunc.parametrize('y', [2, 3])
@ -405,7 +419,8 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect(self):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
metafunc.parametrize('x', [1], indirect=True)
metafunc.parametrize('y', [2, 3], indirect=True)
@ -417,7 +432,8 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect_list(self):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
metafunc.parametrize('x, y', [('a', 'b')], indirect=['x'])
assert metafunc._calls[0].funcargs == dict(y='b')
@ -425,7 +441,8 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect_list_all(self):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
metafunc.parametrize('x, y', [('a', 'b')], indirect=['x', 'y'])
assert metafunc._calls[0].funcargs == {}
@ -433,7 +450,8 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect_list_empty(self):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
metafunc.parametrize('x, y', [('a', 'b')], indirect=[])
assert metafunc._calls[0].funcargs == dict(x='a', y='b')
@ -471,7 +489,8 @@ class TestMetafunc(object):
@pytest.mark.issue714
def test_parametrize_indirect_list_error(self, testdir):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
with pytest.raises(ValueError):
metafunc.parametrize('x, y', [('a', 'b')], indirect=['x', 'z'])
@ -567,7 +586,8 @@ class TestMetafunc(object):
])
def test_addcalls_and_parametrize_indirect(self):
def func(x, y): pass
def func(x, y):
pass
metafunc = self.Metafunc(func)
metafunc.addcall(param="123")
metafunc.parametrize('x', [1], indirect=True)
@ -689,16 +709,20 @@ class TestMetafunc(object):
""")
def test_format_args(self):
def function1(): pass
def function1():
pass
assert fixtures._format_args(function1) == '()'
def function2(arg1): pass
def function2(arg1):
pass
assert fixtures._format_args(function2) == "(arg1)"
def function3(arg1, arg2="qwe"): pass
def function3(arg1, arg2="qwe"):
pass
assert fixtures._format_args(function3) == "(arg1, arg2='qwe')"
def function4(arg1, *args, **kwargs): pass
def function4(arg1, *args, **kwargs):
pass
assert fixtures._format_args(function4) == "(arg1, *args, **kwargs)"

View File

@ -40,11 +40,14 @@ class TestSetupState(object):
def test_teardown_multiple_one_fails(self, testdir):
r = []
def fin1(): r.append('fin1')
def fin1():
r.append('fin1')
def fin2(): raise Exception('oops')
def fin2():
raise Exception('oops')
def fin3(): r.append('fin3')
def fin3():
r.append('fin3')
item = testdir.getitem("def test_func(): pass")
ss = runner.SetupState()
@ -59,9 +62,11 @@ class TestSetupState(object):
def test_teardown_multiple_fail(self, testdir):
# Ensure the first exception is the one which is re-raised.
# Ideally both would be reported however.
def fin1(): raise Exception('oops1')
def fin1():
raise Exception('oops1')
def fin2(): raise Exception('oops2')
def fin2():
raise Exception('oops2')
item = testdir.getitem("def test_func(): pass")
ss = runner.SetupState()

View File

@ -196,6 +196,6 @@ filterwarnings =
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
[flake8]
ignore = E704,E712,E731
ignore = E712,E731
max-line-length = 120
exclude = _pytest/vendored_packages/pluggy.py