Код: Выделить всё
sc = samplechecker(json_root, 'target_file_to_check', {params})
result = sc.run()
res = sc.getId()
taskIds.append(res['data']['Id'])
assert result
Код: Выделить всё
try :
sc = samplechecker(json_root, 'target_file_to_check', {params})
except FileNotFoundError as exc:
pytest.skip(f"!!! Target file {exc.filename} not found !!!")
result = sc.run()
res = sc.getId()
taskIds.append(res['data']['Id'])
assert result
Код: Выделить всё
in conftest.py :
import pytest
@pytest.hookimpl()
def pytest_exception_interact(node, call, report):
excinfo = call.excinfo
excvalue = excinfo.value
if excinfo.type == FileNotFoundError:
pytest.skip(f"!!! Target file {excvalue.filename} not found !!!")
Код: Выделить всё
...
INTERNALERROR> File "/home/jyoun/work/venv_xdr-ac/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/home/jyoun/work/venv_xdr-ac/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/jyoun/work/venv_xdr-ac/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/jyoun/work/venv_xdr-ac/git/SOC-SampleCode/api_reference/test/conftest.py", line 26, in pytest_exception_interact
INTERNALERROR> pytest.skip(f"!!! Target file {excvalue.filename} not found !!!")
INTERNALERROR> File "/home/jyoun/work/venv_xdr-ac/lib/python3.7/site-packages/_pytest/outcomes.py", line 112, in skip
INTERNALERROR> raise Skipped(msg=msg, allow_module_level=allow_module_level)
INTERNALERROR> Skipped: !!! Target file ../sample/targetfile1 not found !!!
Подробнее здесь: https://stackoverflow.com/questions/635 ... -exception