I have some fixtures that just return the objects of a class. The objects contain a property of that class which I am trying to verify in pytest, so the code looks something like this:
from main import My_class
import pytest
@pytest.fixture()
def fixt1():
object1 = My_class("atr1", "atr2")
return object1
@pytest.fixture()
def fixt2():
object2 = My_class("atr3", "atr4")
return object2
@pytest.mark.parametrize('inputs, results',
[
(fixt1, 10.0),
(fixt2, 22.5)
]
)
def test_fixts(inputs, results):
assert inputs.price == results
This code will always return Attribute error:
AttributeError: 'function' object has no attribute 'price'
However, attempting to test these attributes with simple tests like this will work:
def test_simple(fixt1):
assert fixt1.price == 10.0
Can I get some advice on this issue, as I couldn't find instructions on how to properly call objects attributes in parametrize anywhere?
Much appreciated!