How to collect test nodes/names, test outcomes and their associated markers? #10319
Unanswered
matijadurdek
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Try using @pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
rep = outcome.get_result()
target_mark = next(filter(lambda x: x.name == 'mycustommark', item.own_markers), None)
if call.when == 'call' and target_mark:
print('\n')
print("Test node: ", item.nodeid)
print("Marker: ", target_mark.args[0])
print("Test outcome: ", rep.outcome) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I would need some help :)
I want to collect 3 types of data from a test run:
Is it possible to collect the custom markers associated to test methods/nodes and the corresponding test outcomes?
Here is what I currently have in my setup:
pytest.ini:
test examples:
conftest.py:
I tried to use the
pytest_runtest_logreport
hook and it gives me the expected nodes and their outcomes in the output, but I'm not able to fetch the argument values from themycustommark
markers. It returns an integer value:The expected output that I want:
Beta Was this translation helpful? Give feedback.
All reactions