Skip to content

pytest_runtest_call() runs item twice #8868

Answered by bluetech
joshua-badger asked this question in Q&A
Discussion options

You must be logged in to vote

When multiple plugins implement a hook, pytest calls all of them (unless the hook is defined as firstresult, which pytest_runtest_call isn't). This means pytest calls your hook implementation in addition to the built-in pytest implementation.

In your example, you should be able to just remove the item.runtest() call as pytest already does that. To make sure your hook implementation runs after all of the others, you can mark it as trylast=True:

@pytest.hookimpl(trylast=True)
def pytest_runtest_call(item):
    ...

Let me know if it's not clear or doesn't work as expected.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@RonnyPfannschmidt
Comment options

@joshua-badger
Comment options

@joshua-badger
Comment options

@Formartha
Comment options

@RonnyPfannschmidt
Comment options

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
4 participants