I have a fixture that creates an object I use in many tests.
This Object has a property - priority
(1 - 10)
Now, there are a lot of tests that need to "know" the priority of the object (in order to test various logic paths)
So I could have 10 different fixtures:
@pytest.fixture
def object_priority_1():
return MyObj(priority=1)
@pytest.fixture
def object_priority_2():
return MyObj(priority=2)
//....
@pytest.fixture
def object_priority_10():
return MyObj(priority=10)
But it seems off... I'm sure there is a way to deliver an external param to a fixture each time - I just couldn't find it
Edit: To clarify - I would have wanted something in the area of:
@pytest.fixture
def my_object(<priority as an external param>):
return MyObj(priority)
And then the test would be something like:
def test_foo(my_object(1), my_object(6)):
//...