in conftest.py [0:0]
def pytest_exception_interact(node, call, report):
"""
Method that wraps all test execution, on any exception/failure an artifact with the information about the failure is kept.
"""
if report.failed:
try:
test_name = node.name
test_name = sanitize_filename(test_name)
logging.info(f"Handling exception for test: {test_name}")
if hasattr(node, "funcargs"):
logging.info(
f"NODE LOGS HERE {node.funcargs}\n THE FAILED TEST: {test_name}"
)
driver = node.funcargs.get("driver")
opt_ci = node.funcargs.get("opt_ci")
if driver and opt_ci:
logging.info("Writing artifacts...")
log_content(opt_ci, driver, test_name)
screenshot_content(driver, opt_ci, test_name)
else:
logging.error("Error occurred during collection.")
except Exception:
logging.error("Something went wrong with the exception catching.")