Is there a way to somehow use pytest fixtures from conftest.py in a test class\'s setup? I need to initialize an object when the session starts and use it in so
I don't think you can do it directly. However, you can decorate the whole class with pytest.mark.usefixtures, if that helps:
@pytest.mark.usefixtures(['myfixture'])
class TestAAA(object):
...
IIRC, setup_method
will be called before any of the automatically applied fixtures.
You can also utilize autouse for class-level fixtures like so:
class TestAAA(object):
@pytest.fixture(autouse=True)
def init_aaa(self, myfixture):
...