diff --git a/nwb_linkml/src/nwb_linkml/config.py b/nwb_linkml/src/nwb_linkml/config.py index 8a8866e..0d55020 100644 --- a/nwb_linkml/src/nwb_linkml/config.py +++ b/nwb_linkml/src/nwb_linkml/config.py @@ -37,6 +37,7 @@ class Config(BaseSettings): @field_validator('cache_dir', mode='before') @classmethod def folder_exists(cls, v: Path, info: FieldValidationInfo) -> Path: + v = Path(v) v.mkdir(exist_ok=True) assert v.exists() return v diff --git a/nwb_linkml/tests/fixtures.py b/nwb_linkml/tests/fixtures.py index 6c7a3ef..bb33a90 100644 --- a/nwb_linkml/tests/fixtures.py +++ b/nwb_linkml/tests/fixtures.py @@ -1,4 +1,5 @@ import pytest +import os from nwb_linkml.io import schema as io from nwb_linkml.adapters.namespaces import NamespacesAdapter @@ -14,9 +15,15 @@ def tmp_output_dir() -> Path: return path +@pytest.fixture(autouse=True, scope='session') +def set_config_vars(tmp_output_dir): + os.environ['NWB_LINKML_CACHE_DIR'] = str(tmp_output_dir) + + @pytest.fixture(scope="session") def nwb_core_fixture() -> NamespacesAdapter: nwb_core = io.load_nwb_core() nwb_core.populate_imports() - return nwb_core \ No newline at end of file + return nwb_core + diff --git a/nwb_linkml/tests/test_io/test_io_hdf5.py b/nwb_linkml/tests/test_io/test_io_hdf5.py index bae1578..4592cbc 100644 --- a/nwb_linkml/tests/test_io/test_io_hdf5.py +++ b/nwb_linkml/tests/test_io/test_io_hdf5.py @@ -2,7 +2,7 @@ import pytest from pathlib import Path from nwb_linkml.io.hdf5 import HDF5IO - +@pytest.mark.skip() def test_hdf_read(): NWBFILE = Path('/Users/jonny/Dropbox/lab/p2p_ld/data/nwb/sub-738651046_ses-760693773.nwb') if not NWBFILE.exists(): diff --git a/nwb_linkml/tests/test_providers/test_provider_git.py b/nwb_linkml/tests/test_providers/test_provider_git.py index 55665b2..0df4329 100644 --- a/nwb_linkml/tests/test_providers/test_provider_git.py +++ b/nwb_linkml/tests/test_providers/test_provider_git.py @@ -8,7 +8,7 @@ from nwb_schema_language import Namespaces @pytest.mark.parametrize( ['source', 'commit'], [ - (NWB_CORE_REPO, 'b4f8838cbfbb7f8a117bd7e0aad19133d26868b4'), + (NWB_CORE_REPO, '761a0d7838304864643f8bc3ab88c93bfd437f2a'), (HDMF_COMMON_REPO, '660b6ac0780dd9d2cb1e56fea8b62c671ca5e2c8') ] ) diff --git a/nwb_linkml/tests/test_providers/test_provider_schema.py b/nwb_linkml/tests/test_providers/test_provider_schema.py index 383eb98..392dbf1 100644 --- a/nwb_linkml/tests/test_providers/test_provider_schema.py +++ b/nwb_linkml/tests/test_providers/test_provider_schema.py @@ -1,8 +1,9 @@ import pdb import shutil +import os from typing import Optional, Union, List -from ..fixtures import tmp_output_dir +from ..fixtures import tmp_output_dir, set_config_vars import pytest @@ -63,6 +64,10 @@ def test_linkml_provider(tmp_output_dir, repo_version, schema_version, schema_di ) def test_pydantic_provider(tmp_output_dir, class_name, test_fields): provider = PydanticProvider(path=tmp_output_dir) + # clear any prior output + assert provider.path.parent == tmp_output_dir + shutil.rmtree(provider.path, ignore_errors=True) + assert not provider.path.exists() core = provider.get('core') @@ -76,5 +81,3 @@ def test_pydantic_provider(tmp_output_dir, class_name, test_fields): assert test_class.model_fields[k].annotation == v - pdb.set_trace() -