Skip to content

How to reference one of two parameters from test on fixtures? #10040

Answered by nicoddemus
julianonunes asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @julianonunes,

You should use the same name of the fixtures that you want the pass the parameters to, and also access the parametrization value using request.param, see Indirect parametrization in the documentation.

Updated your example (only the relevant parts):

@pytest.fixture
def mocker_create_post(mocker, request):
    post = Post(
        id=0,
        title='New Post Title',
        body='Body',
        tags=request.param
    )

    return mocker.patch('path.to.create_post', return_value=post)

@pytest.fixture
def mocker_search_comments(mocker, request):
    comment = Comment(
        id=1,
        content='Comment content',
        moderation_date=request.param
    )

    patch = 

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@julianonunes
Comment options

@nicoddemus
Comment options

@nicoddemus
Comment options

@julianonunes
Comment options

Answer selected by julianonunes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants