Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pytest
- @pytest.hookimpl(hookwrapper=True)
- def pytest_runtest_makereport(item):
- outcome = yield
- report = outcome.get_result()
- parametrize_mark = item.get_marker('parametrize')
- if report.failed and parametrize_mark:
- # @pytest.mark.parametrize can accept "x, y" or ["x", "y"] as argument names
- args = parametrize_mark.args[0]
- if isinstance(args, str):
- args = [x.strip() for x in args.split(',')]
- # obtain the value of each parametrized argument
- request = item._request
- param_values = {attr: request.getfixturevalue(attr) for attr in args}
- print('\n', item.nodeid, 'failed, parametrize args:', param_values)
Add Comment
Please, Sign In to add comment