1 year ago
#74171
pat987
How to access invoked functions parameters from pytest_runtest_makereport
I'm trying to make custom pytest flag, which will store copy of result files when this flag is used. To do this, I need to access retroactively some other functions that were invoked during test run and pass in conftest their arguments, so based on that, my "store-copy-of-results-files function" should know what type of files it has to look for.
I managed to do that this way:
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
if report.when == 'call':
if STORE_REFERENCEDATA:
acceptedFiles = call.excinfo.traceback[2].locals['expression']
By traceback[2]
I can access function that was called before test run and get it's arguments. However, this works only if test fail, e.g. when regression files are missing or are different from actual results. But if test pass, I can't no longer access this arguments, because excinfo
is empty.
Is it possible to do this in this way somehow, or do I need to do it differently?
python
pycharm
pytest
0 Answers
Your Answer