1
1
"""Test various makers"""
2
2
3
3
import json
4
- import os
5
4
6
5
import pytest
7
6
8
- cwd = os .getcwd ()
9
7
10
-
11
- def test_phonon_flow (si , tmp_path , mock_aims , species_dir ):
8
+ def test_phonon_flow (si , clean_dir , mock_aims , species_dir ):
12
9
import numpy as np
13
10
from jobflow import run_locally
14
11
from pymatgen .io .aims .sets .core import StaticSetGenerator
@@ -57,9 +54,7 @@ def test_phonon_flow(si, tmp_path, mock_aims, species_dir):
57
54
)
58
55
59
56
# run the flow or job and ensure that it finished running successfully
60
- os .chdir (tmp_path )
61
57
responses = run_locally (flow , create_folders = True , ensure_success = True )
62
- os .chdir (cwd )
63
58
64
59
# validation the outputs of the job
65
60
output = responses [flow .job_uuids [- 1 ]][1 ].output
@@ -100,7 +95,7 @@ def test_phonon_flow(si, tmp_path, mock_aims, species_dir):
100
95
101
96
102
97
@pytest .mark .skip (reason = "Currently not mocked and needs FHI-aims binary" )
103
- def test_phonon_socket_flow (si , tmp_path , mock_aims , species_dir ):
98
+ def test_phonon_socket_flow (si , clean_dir , mock_aims , species_dir ):
104
99
import numpy as np
105
100
from jobflow import run_locally
106
101
from pymatgen .io .aims .sets .core import StaticSetGenerator
@@ -153,9 +148,7 @@ def test_phonon_socket_flow(si, tmp_path, mock_aims, species_dir):
153
148
)
154
149
155
150
# run the flow or job and ensure that it finished running successfully
156
- os .chdir (tmp_path )
157
151
responses = run_locally (flow , create_folders = True , ensure_success = True )
158
- os .chdir (cwd )
159
152
160
153
# validation the outputs of the job
161
154
output = responses [flow .job_uuids [- 1 ]][1 ].output
@@ -194,9 +187,10 @@ def test_phonon_socket_flow(si, tmp_path, mock_aims, species_dir):
194
187
assert np .round (output .phonon_bandstructure .bands [- 1 , 0 ], 2 ) == 14.41
195
188
196
189
197
- def test_phonon_default_flow (si , tmp_path , mock_aims , species_dir ):
190
+ def test_phonon_default_flow (si , clean_dir , mock_aims , species_dir ):
198
191
import numpy as np
199
192
from jobflow import run_locally
193
+ from pymatgen .core import SETTINGS
200
194
201
195
from atomate2 .aims .flows .phonons import PhononMaker
202
196
@@ -213,8 +207,8 @@ def test_phonon_default_flow(si, tmp_path, mock_aims, species_dir):
213
207
# automatically use fake FHI-aims
214
208
mock_aims (ref_paths , fake_run_aims_kwargs )
215
209
216
- aims_sd = os . environ .get ("AIMS_SPECIES_DIR" )
217
- os . environ ["AIMS_SPECIES_DIR" ] = str (species_dir / "light" )
210
+ aims_sd = SETTINGS .get ("AIMS_SPECIES_DIR" )
211
+ SETTINGS ["AIMS_SPECIES_DIR" ] = str (species_dir / "light" )
218
212
219
213
maker = PhononMaker ()
220
214
maker .name = "phonons"
@@ -224,9 +218,7 @@ def test_phonon_default_flow(si, tmp_path, mock_aims, species_dir):
224
218
)
225
219
226
220
# run the flow or job and ensure that it finished running successfully
227
- os .chdir (tmp_path )
228
221
responses = run_locally (flow , create_folders = True , ensure_success = True )
229
- os .chdir (cwd )
230
222
231
223
# validation the outputs of the job
232
224
output = responses [flow .job_uuids [- 1 ]][1 ].output
@@ -265,18 +257,19 @@ def test_phonon_default_flow(si, tmp_path, mock_aims, species_dir):
265
257
assert np .round (output .phonon_bandstructure .bands [- 1 , 0 ], 2 ) == 15.02
266
258
267
259
if aims_sd is not None :
268
- os . environ ["AIMS_SPECIES_DIR" ] = aims_sd
260
+ SETTINGS ["AIMS_SPECIES_DIR" ] = aims_sd
269
261
270
262
271
263
@pytest .mark .skip (reason = "Currently not mocked and needs FHI-aims binary" )
272
- def test_phonon_default_socket_flow (si , tmp_path , mock_aims , species_dir ):
264
+ def test_phonon_default_socket_flow (si , clean_dir , mock_aims , species_dir ):
273
265
import numpy as np
274
266
from jobflow import run_locally
267
+ from pymatgen .core import SETTINGS
275
268
276
269
from atomate2 .aims .flows .phonons import PhononMaker
277
270
278
- aims_sd = os . environ .get ("AIMS_SPECIES_DIR" )
279
- os . environ ["AIMS_SPECIES_DIR" ] = str (species_dir / "light" )
271
+ aims_sd = SETTINGS .get ("AIMS_SPECIES_DIR" )
272
+ SETTINGS ["AIMS_SPECIES_DIR" ] = str (species_dir / "light" )
280
273
281
274
# mapping from job name to directory containing test files
282
275
ref_paths = {
@@ -301,9 +294,7 @@ def test_phonon_default_socket_flow(si, tmp_path, mock_aims, species_dir):
301
294
)
302
295
303
296
# run the flow or job and ensure that it finished running successfully
304
- os .chdir (tmp_path )
305
297
responses = run_locally (flow , create_folders = True , ensure_success = True )
306
- os .chdir (cwd )
307
298
308
299
# validation the outputs of the job
309
300
output = responses [flow .job_uuids [- 1 ]][1 ].output
@@ -343,4 +334,4 @@ def test_phonon_default_socket_flow(si, tmp_path, mock_aims, species_dir):
343
334
assert np .round (output .phonon_bandstructure .bands [- 1 , 0 ], 2 ) == 15.02
344
335
345
336
if aims_sd is not None :
346
- os . environ ["AIMS_SPECIES_DIR" ] = aims_sd
337
+ SETTINGS ["AIMS_SPECIES_DIR" ] = aims_sd
0 commit comments