Closed
Description
Originally reported by: BitBucket: virtuald, GitHub: virtuald
What I'd like to be able to do is write a pytest plugin that would check proper usage of a fixture after a test has completed. If the test has failed, then I'd like to not do the check, since the additional error message would confuse the user.
I found a way to do it, but since I'm using an internal variable I suspect that it might be subject to breakage. Here's what I'm doing now:
#!python
def pytest_runtest_setup(item):
item.__testsfailed = item.session._testsfailed
def pytest_runtest_teardown(item):
if fixture_enabled and item.__testsfailed == item.session._testsfailed:
# assert that the fixture was used properly
I'm open to other ways of implementing this, particularly if there's an officially supported way to do it. Thanks!