Created
April 16, 2019 11:24
-
-
Save jaforsgren/378505269717fc1d13d6c98ab5f277b3 to your computer and use it in GitHub Desktop.
pytest fixture report ion failiure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.hookimpl(tryfirst=True, hookwrapper=True) | |
def pytest_runtest_makereport(item, call): | |
# execute all other hooks to obtain the report object | |
outcome = yield | |
rep = outcome.get_result() | |
# set a report attribute for each phase of a call, which can | |
# be "setup", "call", "teardown" | |
setattr(item, "rep_" + rep.when, rep) | |
@pytest.fixture | |
def something(request): | |
yield | |
# request.node is an "item" because we use the default | |
# "function" scope | |
if request.node.rep_setup.failed: | |
print("setting up a test failed!", request.node.nodeid) | |
elif request.node.rep_setup.passed: | |
if request.node.rep_call.failed: | |
print(request.node.user_properties) | |
print("executing test failed uwu ", request.node.nodeid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment