Files
StarPilot/tinygrad_repo/conftest.py
T
2026-10-20 03:55:45 +00:00

20 lines
684 B
Python

import os, pytest, faulthandler
stderr_fd_key = pytest.StashKey[int]()
def pytest_configure(config):
# dup stderr so that we can still write to it in faulthandler even if stderr would be captured
config.stash[stderr_fd_key] = fd = os.dup(2)
config.add_cleanup(lambda: os.close(fd))
@pytest.hookimpl(wrapper=True)
def pytest_runtest_call(item):
faulthandler.dump_traceback_later(int(os.getenv("TEST_TIMEOUT", 180)), file=item.config.stash[stderr_fd_key], exit=True)
try: yield
finally: faulthandler.cancel_dump_traceback_later()
@pytest.fixture(autouse=True)
def clear_runtime_cache():
yield
from tinygrad.engine.realize import runtime_cache
runtime_cache.clear()