Guest User

Untitled

a guest
Mar 17th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import pytest
  2.  
  3.  
  4. @pytest.hookimpl(hookwrapper=True)
  5. def pytest_runtest_makereport(item):
  6. outcome = yield
  7. report = outcome.get_result()
  8. parametrize_mark = item.get_marker('parametrize')
  9. if report.failed and parametrize_mark:
  10. # @pytest.mark.parametrize can accept "x, y" or ["x", "y"] as argument names
  11. args = parametrize_mark.args[0]
  12. if isinstance(args, str):
  13. args = [x.strip() for x in args.split(',')]
  14.  
  15. # obtain the value of each parametrized argument
  16. request = item._request
  17. param_values = {attr: request.getfixturevalue(attr) for attr in args}
  18. print('\n', item.nodeid, 'failed, parametrize args:', param_values)
Add Comment
Please, Sign In to add comment