Skip to content

dynamically generated fixtures #2424

@majuscule

Description

@majuscule

This is a feature request. I would like to be able to dynamically generate fixtures, similar to parameterized fixtures, but instead of running all associated tests with each fixture, expose each fixture dynamically. The syntax could use work, but i.e.:

@pytest.fixture(scope='module',
                generate=['user', 'admin'],
                params=[User, Admin])
def session(SessionType):
    return SessionType()

def test_authorization(session_user, session_admin):
    with pytest.raises(Exception):
        session_user.do_admin_thing()
     assert session_admin.do_admin_thing()

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: fixturesanything involving fixtures directly or indirectlytype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions