Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move _clear_tracked_cache fixture #307

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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