I'm writing some tests with pytest and have what I believe is a simple question but am not sure the right way to do it. I have some code like this:
@pytest.fixture
def obj1():
...setup object 1...
return obj
@pytest.fixture
def obj2():
....setup object 2 ...
return obj
def test_val_obj_1(obj1):
...some common boilerplate...
output = some_function(obj1)
assert output['important_key'] == some_values
def test_val_obj_2(obj2):
...some common boilerplate...
output = some_function(obj2)
assert output['important_key'] == some_values
For my two tests, the ...some common boilerplate... and some_function() are the same, and so I would prefer to have this elsewhere. Do I just define a normal function to do this? Or do I need to do something specific with fixtures? I haven't totally wrapped my head about the "parameterized" fixtures in the docs and can't figure out if that's what I'm asking about or if that's a different use case.