from pathlib import Path

import pytest
from pymatgen.core import SETTINGS

@pytest.fixture(scope="session")
def test_dir():
    try:
        TEST_FILES_DIR = Path(SETTINGS["PMG_TEST_FILES_DIR"])
    except KeyError:
        import warnings
        warnings.warn(
            "It is recommended that you set the PMG_TEST_FILES_DIR environment variable explicitly. "
            "Now using a fallback location based on relative path from this module."
        )
        TEST_FILES_DIR = Path(__file__).parent.parent.parent.joinpath("test_files").resolve()
    return TEST_FILES_DIR
