I have a function and a test
def foo(a):
return bar(a)
@pytest.mark.parametrize(
'number',
[1,2,3]
)
@pytest.mark.dependency
def test_foo(number):
assert foo(number) > SOME_CONST # Simplistic example, real case is more nuanced
I'm using pytest and the pytest_dependency module. foo
is a function used in a number of other tests. I have a function which I want to play a dependency on test_foo
, the code below doesn't work:
@pytest.mark.dependency(depends=['test_foo'])
@pytest.mark.parametrize(
'param',
itertools.permutations(['a','b','c','d','e'],2),
ids=repr,
)
def test_bar(param):
...
important_result = foo(param)
...
The theory is that if test_foo
fails, then test_bar
will be skipped. However, when I parametrize test_bar
, each instantiation of test_bar
is skipped regardless of the result of test_foo
.
To clarify, this code works as expected (test_bar is not skipped):
@pytest.mark.dependency(depends=['test_foo'])
def test_bar():
param = some_fnc(['a', 'b'])
...
important_result = foo(param)
...