Skip to content

Mark kwargs sometimes not passed into request.node #8530

Answered by AAAver
AAAver asked this question in Q&A
Discussion options

You must be logged in to vote

Finally I've found my mistake in code

@pytest.fixture()
def some_fixture(request):
    marker = request.node.get_closest_marker("some_fixture_params")
    some_params = {}
    num = None
    if marker:
        if 'num' in marker.kwargs.keys():
            num = marker.kwargs['num']
            marker.kwargs.pop('num')
            some_params.update(marker.kwargs)


@mark.some_fixture_params(num=1)
def test_xxx(some_fixture):
    assert False

The case was that for some reasons I had to pop number parameter from kwargs and update other parameter with that that was left in kwargs
So if test failed for some reason and reruns I had already poped number parameter from mark. I did not know that…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by RonnyPfannschmidt
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
Converted from issue

This discussion was converted from issue #8527 on April 08, 2021 14:10.