Skip to content

Commit

Permalink
Refactor test to dump transformations.json to tmpdir
Browse files Browse the repository at this point in the history
  • Loading branch information
esoteric-ephemera committed Apr 3, 2024
1 parent 8245ad2 commit c644899
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
11 changes: 8 additions & 3 deletions emmet-core/tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ def test_output_summary(test_dir, object_name, task_name):
pytest.param("SiNonSCFUniform", id="SiNonSCFUniform"),
],
)
def test_task_doc(test_dir, object_name):
def test_task_doc(test_dir, object_name, tmpdir):
from monty.json import jsanitize
from monty.serialization import dumpfn
import os
from pymatgen.alchemy.materials import TransformedStructure
from pymatgen.entries.computed_entries import ComputedEntry
from pymatgen.transformations.standard_transformations import (
DeformStructureTransformation,
)
import shutil

from emmet.core.tasks import TaskDoc

Expand Down Expand Up @@ -156,8 +158,11 @@ def test_task_doc(test_dir, object_name):
],
)
ts_json = jsanitize(ts.as_dict())
dumpfn(ts, f"{dir_name}/transformations.json")
test_doc = TaskDoc.from_directory(dir_name)
dumpfn(ts, f"{tmpdir}/transformations.json")
for f in os.listdir(dir_name):
if os.path.isfile(os.path.join(dir_name, f)):
shutil.copy(os.path.join(dir_name, f), tmpdir)
test_doc = TaskDoc.from_directory(tmpdir)
# if other_parameters == {}, this is popped from the TaskDoc.transformations field
# seems like @version is added by monty serialization
# jsanitize needed because pymatgen.core.Structure.pbc is a tuple
Expand Down
1 change: 0 additions & 1 deletion test_files/vasp/Si_old_double_relax/transformations.json

This file was deleted.

1 change: 0 additions & 1 deletion test_files/vasp/Si_static/transformations.json

This file was deleted.

1 change: 0 additions & 1 deletion test_files/vasp/Si_uniform/transformations.json

This file was deleted.

0 comments on commit c644899

Please sign in to comment.