testing/python/fixtures.py: use NotImplementedError pattern

This commit is contained in:
Daniel Hahler 2019-08-16 00:09:14 +02:00
parent 4c37dca011
commit 6ead01aacd
1 changed files with 10 additions and 10 deletions

View File

@ -14,22 +14,22 @@ def test_getfuncargnames_functions():
"""Test getfuncargnames for normal functions"""
def f():
pass
raise NotImplementedError()
assert not fixtures.getfuncargnames(f)
def g(arg):
pass
raise NotImplementedError()
assert fixtures.getfuncargnames(g) == ("arg",)
def h(arg1, arg2="hello"):
pass
raise NotImplementedError()
assert fixtures.getfuncargnames(h) == ("arg1",)
def j(arg1, arg2, arg3="hello"):
pass
raise NotImplementedError()
assert fixtures.getfuncargnames(j) == ("arg1", "arg2")
@ -39,7 +39,7 @@ def test_getfuncargnames_methods():
class A:
def f(self, arg1, arg2="hello"):
pass
raise NotImplementedError()
assert fixtures.getfuncargnames(A().f) == ("arg1",)
@ -50,7 +50,7 @@ def test_getfuncargnames_staticmethod():
class A:
@staticmethod
def static(arg1, arg2, x=1):
pass
raise NotImplementedError()
assert fixtures.getfuncargnames(A.static, cls=A) == ("arg1", "arg2")
@ -60,7 +60,7 @@ def test_getfuncargnames_partial():
import functools
def check(arg1, arg2, i):
pass
raise NotImplementedError()
class T:
test_ok = functools.partial(check, i=2)
@ -74,7 +74,7 @@ def test_getfuncargnames_staticmethod_partial():
import functools
def check(arg1, arg2, i):
pass
raise NotImplementedError()
class T:
test_ok = staticmethod(functools.partial(check, i=2))
@ -3355,7 +3355,7 @@ class TestShowFixtures:
@pytest.fixture
@pytest.fixture
def foo():
pass
raise NotImplementedError()
class TestContextManagerFixtureFuncs:
@ -3981,7 +3981,7 @@ def test_call_fixture_function_error():
@pytest.fixture
def fix():
return 1
raise NotImplementedError()
with pytest.raises(pytest.fail.Exception):
assert fix() == 1