Единственный возможный обходной путь, о котором я могу подумать, - это построить стратегию внутри теста и использовать data
стратегии для рисования примеров, что-то вроде
import pytest
from hypothesis import given
from hypothesis import strategies as st
@st.composite
def my_strategy(draw, attribute):
# Body of my strategy
return # Something...
@given(data=st.data())
@pytest.mark.parametrize("attribute", [1, 2, 3])
def test_foo(attribute, data):
strategy = my_strategy(attribute)
example = data.draw(strategy)
... # rest of the test
Но я думаю, что лучше можно будет написать стратегию, не смешивая ее с mark.parametrize
:
@given(st.sampled_from([1, 2, 3]).flatmap(my_strategy))
def test_foo(example):
... # rest of the test