diff --git a/src/conftest.py b/src/conftest.py index 7e714ee..f8185d4 100644 --- a/src/conftest.py +++ b/src/conftest.py @@ -5,12 +5,12 @@ # sys.path. It is thus good practise for projects to either put conftest.py under # a package scope or to never import anything from a conftest.py file. -import os.path from pathlib import Path import pytest from dirmanager import DirManager from dotenv import dotenv_values +from icecream import ic from playwright.sync_api import BrowserContext pytest_plugins = [ @@ -79,8 +79,12 @@ def pytest_runtest_makereport(item, call): # we only look at actual failing test calls, not setup/teardown if rep.when == "call" and rep.failed: - mode = "a" if os.path.exists("failures") else "w" - with open("failures", mode) as f: + # saves traceback as .txt for failed test + filename = f"failed-{item.nodeid}.txt" + filename = filename.replace("/", "-") + filename = filename.replace("::", "-") + filepath = item.funcargs["RESULTS"] / filename + with open(filepath, "a") as f: f.write(rep.longreprtext + "\n")