Fix flake8 E305 and E306 errors
These errors started to appear with flake8-3.1.1, while they don't appear with version 3.1.0 (weird).
This commit is contained in:
@@ -383,10 +383,13 @@ class TestFunction:
|
||||
config = testdir.parseconfigure()
|
||||
session = testdir.Session(config)
|
||||
session._fixturemanager = FixtureManager(session)
|
||||
|
||||
def func1():
|
||||
pass
|
||||
|
||||
def func2():
|
||||
pass
|
||||
|
||||
f1 = pytest.Function(name="name", parent=session, config=config,
|
||||
args=(1,), callobj=func1)
|
||||
assert f1 == f1
|
||||
@@ -547,12 +550,15 @@ class TestFunction:
|
||||
def test_pyfunc_call(self, testdir):
|
||||
item = testdir.getitem("def test_func(): raise ValueError")
|
||||
config = item.config
|
||||
|
||||
class MyPlugin1:
|
||||
def pytest_pyfunc_call(self, pyfuncitem):
|
||||
raise ValueError
|
||||
|
||||
class MyPlugin2:
|
||||
def pytest_pyfunc_call(self, pyfuncitem):
|
||||
return True
|
||||
|
||||
config.pluginmanager.register(MyPlugin1())
|
||||
config.pluginmanager.register(MyPlugin2())
|
||||
config.hook.pytest_runtest_setup(item=item)
|
||||
|
||||
@@ -10,15 +10,20 @@ from _pytest import fixtures
|
||||
def test_getfuncargnames():
|
||||
def f(): pass
|
||||
assert not fixtures.getfuncargnames(f)
|
||||
|
||||
def g(arg): pass
|
||||
assert fixtures.getfuncargnames(g) == ('arg',)
|
||||
|
||||
def h(arg1, arg2="hello"): pass
|
||||
assert fixtures.getfuncargnames(h) == ('arg1',)
|
||||
|
||||
def h(arg1, arg2, arg3="hello"): pass
|
||||
assert fixtures.getfuncargnames(h) == ('arg1', 'arg2')
|
||||
|
||||
class A:
|
||||
def f(self, arg1, arg2="hello"):
|
||||
pass
|
||||
|
||||
assert fixtures.getfuncargnames(A().f) == ('arg1',)
|
||||
if sys.version_info < (3,0):
|
||||
assert fixtures.getfuncargnames(A.f) == ('arg1',)
|
||||
@@ -869,8 +874,10 @@ class TestRequestCachedSetup:
|
||||
item1 = testdir.getitem("def test_func(): pass")
|
||||
req1 = fixtures.FixtureRequest(item1)
|
||||
l = ["hello", "world"]
|
||||
|
||||
def setup():
|
||||
return l.pop()
|
||||
|
||||
ret1 = req1.cached_setup(setup, extrakey=1)
|
||||
ret2 = req1.cached_setup(setup, extrakey=2)
|
||||
assert ret2 == "hello"
|
||||
@@ -884,10 +891,13 @@ class TestRequestCachedSetup:
|
||||
item1 = testdir.getitem("def test_func(): pass")
|
||||
req1 = fixtures.FixtureRequest(item1)
|
||||
l = []
|
||||
|
||||
def setup():
|
||||
l.append("setup")
|
||||
|
||||
def teardown(val):
|
||||
l.append("teardown")
|
||||
|
||||
req1.cached_setup(setup, teardown, scope="function")
|
||||
assert l == ['setup']
|
||||
# artificial call of finalizer
|
||||
|
||||
@@ -63,10 +63,12 @@ class TestOEJSKITSpecials:
|
||||
def test_wrapped_getfslineno():
|
||||
def func():
|
||||
pass
|
||||
|
||||
def wrap(f):
|
||||
func.__wrapped__ = f
|
||||
func.patchings = ["qwe"]
|
||||
return func
|
||||
|
||||
@wrap
|
||||
def wrapped_func(x, y, z):
|
||||
pass
|
||||
@@ -77,28 +79,36 @@ def test_wrapped_getfslineno():
|
||||
class TestMockDecoration:
|
||||
def test_wrapped_getfuncargnames(self):
|
||||
from _pytest.compat import getfuncargnames
|
||||
|
||||
def wrap(f):
|
||||
|
||||
def func():
|
||||
pass
|
||||
|
||||
func.__wrapped__ = f
|
||||
return func
|
||||
|
||||
@wrap
|
||||
def f(x):
|
||||
pass
|
||||
|
||||
l = getfuncargnames(f)
|
||||
assert l == ("x",)
|
||||
|
||||
def test_wrapped_getfuncargnames_patching(self):
|
||||
from _pytest.compat import getfuncargnames
|
||||
|
||||
def wrap(f):
|
||||
def func():
|
||||
pass
|
||||
func.__wrapped__ = f
|
||||
func.patchings = ["qwe"]
|
||||
return func
|
||||
|
||||
@wrap
|
||||
def f(x, y, z):
|
||||
pass
|
||||
|
||||
l = getfuncargnames(f)
|
||||
assert l == ("y", "z")
|
||||
|
||||
|
||||
@@ -20,8 +20,10 @@ class TestMetafunc:
|
||||
# initiliazation
|
||||
class FixtureInfo:
|
||||
name2fixturedefs = None
|
||||
|
||||
def __init__(self, names):
|
||||
self.names_closure = names
|
||||
|
||||
names = fixtures.getfuncargnames(func)
|
||||
fixtureinfo = FixtureInfo(names)
|
||||
return python.Metafunc(func, fixtureinfo, None)
|
||||
@@ -65,7 +67,9 @@ class TestMetafunc:
|
||||
def test_addcall_param(self):
|
||||
def func(arg1): pass
|
||||
metafunc = self.Metafunc(func)
|
||||
|
||||
class obj: pass
|
||||
|
||||
metafunc.addcall(param=obj)
|
||||
metafunc.addcall(param=obj)
|
||||
metafunc.addcall(param=1)
|
||||
@@ -76,8 +80,11 @@ class TestMetafunc:
|
||||
|
||||
def test_addcall_funcargs(self):
|
||||
def func(x): pass
|
||||
|
||||
metafunc = self.Metafunc(func)
|
||||
|
||||
class obj: pass
|
||||
|
||||
metafunc.addcall(funcargs={"x": 2})
|
||||
metafunc.addcall(funcargs={"x": 3})
|
||||
pytest.raises(pytest.fail.Exception, "metafunc.addcall({'xyz': 0})")
|
||||
@@ -142,8 +149,10 @@ class TestMetafunc:
|
||||
def test_parametrize_with_userobjects(self):
|
||||
def func(x, y): pass
|
||||
metafunc = self.Metafunc(func)
|
||||
|
||||
class A:
|
||||
pass
|
||||
|
||||
metafunc.parametrize("x", [A(), A()])
|
||||
metafunc.parametrize("y", list("ab"))
|
||||
assert metafunc._calls[0].id == "x0-a"
|
||||
@@ -254,6 +263,7 @@ class TestMetafunc:
|
||||
@pytest.mark.issue351
|
||||
def test_idmaker_idfn(self):
|
||||
from _pytest.python import idmaker
|
||||
|
||||
def ids(val):
|
||||
if isinstance(val, Exception):
|
||||
return repr(val)
|
||||
@@ -270,6 +280,7 @@ class TestMetafunc:
|
||||
@pytest.mark.issue351
|
||||
def test_idmaker_idfn_unique_names(self):
|
||||
from _pytest.python import idmaker
|
||||
|
||||
def ids(val):
|
||||
return 'a'
|
||||
|
||||
@@ -285,6 +296,7 @@ class TestMetafunc:
|
||||
@pytest.mark.issue351
|
||||
def test_idmaker_idfn_exception(self):
|
||||
from _pytest.python import idmaker
|
||||
|
||||
def ids(val):
|
||||
raise Exception("bad code")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user