[Python] Joining the result of two fixtures

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    Suppose I have:

    @pytest.fixture(scope="session", params=FILENAMES1)
    def fixture1 (request):
    ... returns an object based on the filename (request.param)

    @pytest.fixture(scope="session", params=FILENAMES2)
    def fixture2 (request):
    ... returns a differently created object from different filenames ...


    I would like to be able to do something like:

    @pytest.fixture(scope="session")
    def both_fixtures():
    ....??? ...


    where using both_fixtures as an argument to a test will give me both the items from fixture1 and fixture2.

    I am aware that a fixture can access other fixtures, but I do not want their cross product, which is what def new_fixture(fixture1, fixture2) would give me.

    I want the items of fixture1 followed by the items of fixture2.

    Is this doable?

    Continue reading...

Compartilhe esta Página