traceback of failed test gets saved via hook
This commit is contained in:
parent
c71a4db8cb
commit
ab8f068a5e
1 changed files with 7 additions and 3 deletions
|
|
@ -5,12 +5,12 @@
|
||||||
# sys.path. It is thus good practise for projects to either put conftest.py under
|
# 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.
|
# a package scope or to never import anything from a conftest.py file.
|
||||||
|
|
||||||
import os.path
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from dirmanager import DirManager
|
from dirmanager import DirManager
|
||||||
from dotenv import dotenv_values
|
from dotenv import dotenv_values
|
||||||
|
from icecream import ic
|
||||||
from playwright.sync_api import BrowserContext
|
from playwright.sync_api import BrowserContext
|
||||||
|
|
||||||
pytest_plugins = [
|
pytest_plugins = [
|
||||||
|
|
@ -79,8 +79,12 @@ def pytest_runtest_makereport(item, call):
|
||||||
|
|
||||||
# we only look at actual failing test calls, not setup/teardown
|
# we only look at actual failing test calls, not setup/teardown
|
||||||
if rep.when == "call" and rep.failed:
|
if rep.when == "call" and rep.failed:
|
||||||
mode = "a" if os.path.exists("failures") else "w"
|
# saves traceback as .txt for failed test
|
||||||
with open("failures", mode) as f:
|
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")
|
f.write(rep.longreprtext + "\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue