Files
OpenBB/openbb_platform/providers/fred/tests/conftest.py
Danglewood 124a420f79 [V5] openbb-fred: Refactor as V5 extension. (#7669)
* refactor fred extension for v5

* fix markdown MD037 lint error in README

* codespell
2026-09-23 12:54:02 -07:00

30 lines
776 B
Python

"""Shared fixtures for the FRED provider tests."""
import os
import pytest
@pytest.fixture(scope="session", autouse=True)
def fred_cache(tmp_path_factory):
"""Give the run its own FRED response cache, and empty it at the end."""
from openbb_fred.utils import cache
from openbb_fred.utils.rate_limiter import cache_clear
directory = tmp_path_factory.mktemp("fred-cache")
previous = os.environ.get("OPENBB_FRED_DISK_CACHE_DIR")
os.environ["OPENBB_FRED_DISK_CACHE_DIR"] = str(directory)
cache.close()
cache_clear()
yield cache
cache.clear()
cache.close()
cache_clear()
if previous is None:
os.environ.pop("OPENBB_FRED_DISK_CACHE_DIR", None)
else:
os.environ["OPENBB_FRED_DISK_CACHE_DIR"] = previous