Skip to content

Commit

Permalink
Move _clear_tracked_cache fixture (#307)
Browse files Browse the repository at this point in the history
* move _clear_tracked_cache fixture to specific test files

* fix lint
  • Loading branch information
gpetretto authored Nov 17, 2023
1 parent 2020ad4 commit af0c766
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
10 changes: 0 additions & 10 deletions tests/vasp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,3 @@ def _patch_get_potential_energy(monkeypatch):
Monkeypatch the multiprocessing.cpu_count() function to always return 64
"""
monkeypatch.setattr(multiprocessing, "cpu_count", lambda *args, **kwargs: 64)


@pytest.fixture(autouse=True)
def _clear_tracked_cache():
"""
Clear the cache of the stored functions between the tests.
"""
from custodian.utils import tracked_lru_cache

tracked_lru_cache.tracked_cache_clear()
10 changes: 10 additions & 0 deletions tests/vasp/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
os.environ.setdefault("PMG_VASP_PSP_DIR", TEST_FILES)


@pytest.fixture(autouse=True)
def _clear_tracked_cache():
"""
Clear the cache of the stored functions between the tests.
"""
from custodian.utils import tracked_lru_cache

tracked_lru_cache.tracked_cache_clear()


def copy_tmp_files(tmp_path: str, *file_paths: str) -> None:
for file_path in file_paths:
src_path = f"{TEST_FILES}/{file_path}"
Expand Down
12 changes: 12 additions & 0 deletions tests/vasp/test_io.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import pytest

from custodian import TEST_FILES
from custodian.utils import tracked_lru_cache
from custodian.vasp.io import load_outcar, load_vasprun


@pytest.fixture(autouse=True)
def _clear_tracked_cache():
"""
Clear the cache of the stored functions between the tests.
"""
from custodian.utils import tracked_lru_cache

tracked_lru_cache.tracked_cache_clear()


class TestIO:
def test_load_outcar(self):
outcar = load_outcar(f"{TEST_FILES}/large_sigma/OUTCAR")
Expand Down
12 changes: 12 additions & 0 deletions tests/vasp/test_validators.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import os
import shutil

import pytest

from custodian import TEST_FILES
from custodian.vasp.validators import VaspAECCARValidator, VaspFilesValidator, VaspNpTMDValidator, VasprunXMLValidator


@pytest.fixture(autouse=True)
def _clear_tracked_cache():
"""
Clear the cache of the stored functions between the tests.
"""
from custodian.utils import tracked_lru_cache

tracked_lru_cache.tracked_cache_clear()


class TestVasprunXMLValidator:
def test_check_and_correct(self):
os.chdir(f"{TEST_FILES}/bad_vasprun")
Expand Down

0 comments on commit af0c766

Please sign in to comment.