Skip to content

@pytest.mark.order(after) a parameterized function #136

Discussion options

You must be logged in to vote

Ok, this is actually possible. What is not possible is to handle the parametrized tests separately (as you have tried), instead you just have to use the name without the id for the parametrized test:

def test_create():
    pass


@pytest.mark.order(after="test_create")
@pytest.mark.order(after="test_update")
def test_get():
    pass


@pytest.mark.order(after="test_get[after=test_create]")
@pytest.mark.parametrize("key", ["name", "description"])
def test_update(key):
    pass


@pytest.mark.order(after="test_get[after=test_update]")
def test_delete():
    pass

I have to admit that I didn't know that tests that are running more than once are referenced this way - learned something new!

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@mrbean-bremen
Comment options

@GijsPampiermole
Comment options

@mrbean-bremen
Comment options

Answer selected by GijsPampiermole
@GijsPampiermole
Comment options

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