testing/python/fixtures.py: use NotImplementedError pattern
This commit is contained in:
parent
4c37dca011
commit
6ead01aacd
|
@ -14,22 +14,22 @@ def test_getfuncargnames_functions():
|
||||||
"""Test getfuncargnames for normal functions"""
|
"""Test getfuncargnames for normal functions"""
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
pass
|
raise NotImplementedError()
|
||||||
|
|
||||||
assert not fixtures.getfuncargnames(f)
|
assert not fixtures.getfuncargnames(f)
|
||||||
|
|
||||||
def g(arg):
|
def g(arg):
|
||||||
pass
|
raise NotImplementedError()
|
||||||
|
|
||||||
assert fixtures.getfuncargnames(g) == ("arg",)
|
assert fixtures.getfuncargnames(g) == ("arg",)
|
||||||
|
|
||||||
def h(arg1, arg2="hello"):
|
def h(arg1, arg2="hello"):
|
||||||
pass
|
raise NotImplementedError()
|
||||||
|
|
||||||
assert fixtures.getfuncargnames(h) == ("arg1",)
|
assert fixtures.getfuncargnames(h) == ("arg1",)
|
||||||
|
|
||||||
def j(arg1, arg2, arg3="hello"):
|
def j(arg1, arg2, arg3="hello"):
|
||||||
pass
|
raise NotImplementedError()
|
||||||
|
|
||||||
assert fixtures.getfuncargnames(j) == ("arg1", "arg2")
|
assert fixtures.getfuncargnames(j) == ("arg1", "arg2")
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ def test_getfuncargnames_methods():
|
||||||
|
|
||||||
class A:
|
class A:
|
||||||
def f(self, arg1, arg2="hello"):
|
def f(self, arg1, arg2="hello"):
|
||||||
pass
|
raise NotImplementedError()
|
||||||
|
|
||||||
assert fixtures.getfuncargnames(A().f) == ("arg1",)
|
assert fixtures.getfuncargnames(A().f) == ("arg1",)
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ def test_getfuncargnames_staticmethod():
|
||||||
class A:
|
class A:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def static(arg1, arg2, x=1):
|
def static(arg1, arg2, x=1):
|
||||||
pass
|
raise NotImplementedError()
|
||||||
|
|
||||||
assert fixtures.getfuncargnames(A.static, cls=A) == ("arg1", "arg2")
|
assert fixtures.getfuncargnames(A.static, cls=A) == ("arg1", "arg2")
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ def test_getfuncargnames_partial():
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
def check(arg1, arg2, i):
|
def check(arg1, arg2, i):
|
||||||
pass
|
raise NotImplementedError()
|
||||||
|
|
||||||
class T:
|
class T:
|
||||||
test_ok = functools.partial(check, i=2)
|
test_ok = functools.partial(check, i=2)
|
||||||
|
@ -74,7 +74,7 @@ def test_getfuncargnames_staticmethod_partial():
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
def check(arg1, arg2, i):
|
def check(arg1, arg2, i):
|
||||||
pass
|
raise NotImplementedError()
|
||||||
|
|
||||||
class T:
|
class T:
|
||||||
test_ok = staticmethod(functools.partial(check, i=2))
|
test_ok = staticmethod(functools.partial(check, i=2))
|
||||||
|
@ -3355,7 +3355,7 @@ class TestShowFixtures:
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def foo():
|
def foo():
|
||||||
pass
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
class TestContextManagerFixtureFuncs:
|
class TestContextManagerFixtureFuncs:
|
||||||
|
@ -3981,7 +3981,7 @@ def test_call_fixture_function_error():
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def fix():
|
def fix():
|
||||||
return 1
|
raise NotImplementedError()
|
||||||
|
|
||||||
with pytest.raises(pytest.fail.Exception):
|
with pytest.raises(pytest.fail.Exception):
|
||||||
assert fix() == 1
|
assert fix() == 1
|
||||||
|
|
Loading…
Reference in New Issue