Skip to content

Commit c50db64

Browse files
committed
test_dict_set_alias subclass and deprecation message
1 parent 6646b98 commit c50db64

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tests/io/vasp/test_sets.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ def test_sets_changed(self):
128128
assert hashes[input_set] == known_hashes[input_set], f"{input_set=}\n{msg}"
129129

130130

131-
class TestDictSet(PymatgenTest):
131+
class TestVaspInputSet(PymatgenTest):
132132
@classmethod
133133
def setUpClass(cls):
134134
filepath = f"{VASP_IN_DIR}/POSCAR"
135135
cls.structure = Structure.from_file(filepath)
136136

137137
def test_as_dict(self):
138138
# https://github.com/materialsproject/pymatgen/pull/3031
139-
dict_set = DictSet(self.structure, config_dict={"INCAR": {}}, user_potcar_functional="PBE_54")
139+
dict_set = VaspInputSet(self.structure, config_dict={"INCAR": {}}, user_potcar_functional="PBE_54")
140140
assert {*dict_set.as_dict()} >= {
141141
"@class",
142142
"@module",
@@ -1580,7 +1580,7 @@ def test_potcar(self):
15801580
assert input_set.potcar.functional == "PBE_52"
15811581

15821582
with pytest.raises(
1583-
ValueError, match=r"Invalid self.user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
1583+
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
15841584
):
15851585
MVLScanRelaxSet(self.struct, user_potcar_functional="PBE")
15861586

@@ -1597,7 +1597,7 @@ def test_potcar(self):
15971597
#
15981598
# # https://github.com/materialsproject/pymatgen/pull/3022
15991599
# # same test also in MITMPRelaxSetTest above (for redundancy,
1600-
# # should apply to all classes inheriting from DictSet)
1600+
# # should apply to all classes inheriting from VaspInputSet)
16011601
# for user_potcar_settings in [{"Fe": "Fe_pv"}, {"W": "W_pv"}, None]:
16021602
# for species in [("W", "W"), ("Fe", "W"), ("Fe", "Fe")]:
16031603
# struct = Structure(lattice=Lattice.cubic(3), species=species, coords=[[0, 0, 0], [0.5, 0.5, 0.5]])
@@ -1710,7 +1710,7 @@ def test_potcar(self):
17101710
assert input_set.potcar.functional == "PBE_54"
17111711

17121712
with pytest.raises(
1713-
ValueError, match=r"Invalid self.user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
1713+
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
17141714
):
17151715
MPScanRelaxSet(self.struct, user_potcar_functional="PBE")
17161716

@@ -1880,7 +1880,7 @@ def test_potcar(self):
18801880
assert test_potcar_set_1.potcar.functional == "PBE_52"
18811881

18821882
with pytest.raises(
1883-
ValueError, match=r"Invalid self.user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
1883+
ValueError, match=r"Invalid user_potcar_functional='PBE', must be one of \('PBE_52', 'PBE_54'\)"
18841884
):
18851885
self.set(self.struct, user_potcar_functional="PBE")
18861886

@@ -2094,3 +2094,11 @@ def test_as_from_dict(self):
20942094

20952095
def test_vasp_input_set_alias():
20962096
assert VaspInputSet is VaspInputGenerator
2097+
2098+
2099+
def test_dict_set_alias():
2100+
assert isinstance(DictSet(), VaspInputSet)
2101+
with pytest.warns(
2102+
FutureWarning, match="DictSet is deprecated, and will be removed on 2025-12-31\n; use VaspInputSet"
2103+
):
2104+
DictSet()

0 commit comments

Comments
 (0)