2020_ABINIT_FILES = ("run.abi" , "abinit_input.json" )
2121_FAKE_RUN_ABINIT_KWARGS = {}
2222
23+ # Do this here to prevent issues with threaded CI runners
24+ # In abipy, it's possible to have thread collisions in
25+ # making this directory because `exist_ok = False` there
26+ _ABINIT_PATH = Path ("~/.abinit" ).expanduser ()
27+ if not _ABINIT_PATH .is_dir ():
28+ _ABINIT_PATH .mkdir (exist_ok = True , parents = True )
29+
2330
2431@pytest .fixture (scope = "session" )
2532def abinit_test_dir (test_dir ):
@@ -32,7 +39,7 @@ def abinit_integration_tests(pytestconfig):
3239
3340
3441@pytest .fixture
35- def mock_abinit (mocker , abinit_test_dir , abinit_integration_tests ):
42+ def mock_abinit (monkeypatch , abinit_test_dir , abinit_integration_tests ):
3643 """
3744 This fixture allows one to mock running ABINIT.
3845
@@ -56,7 +63,7 @@ def wrapped_write_abinit_input_set(*args, **kwargs):
5663 atomate2 .abinit .files .write_abinit_input_set (* args , ** kwargs )
5764 check_abinit_inputs (ref_path )
5865
59- mocker . patch . object (
66+ monkeypatch . setattr (
6067 atomate2 .abinit .jobs .base ,
6168 "write_abinit_input_set" ,
6269 wrapped_write_abinit_input_set ,
@@ -73,8 +80,8 @@ def mock_run_abinit(wall_time=None, start_time=None):
7380 check_abinit_inputs (ref_path )
7481 fake_run_abinit (ref_path )
7582
76- mocker . patch . object (atomate2 .abinit .run , "run_abinit" , mock_run_abinit )
77- mocker . patch . object (atomate2 .abinit .jobs .base , "run_abinit" , mock_run_abinit )
83+ monkeypatch . setattr (atomate2 .abinit .run , "run_abinit" , mock_run_abinit )
84+ monkeypatch . setattr (atomate2 .abinit .jobs .base , "run_abinit" , mock_run_abinit )
7885
7986 def _run (ref_paths , fake_run_abinit_kwargs = None ):
8087 if fake_run_abinit_kwargs is None :
@@ -84,7 +91,7 @@ def _run(ref_paths, fake_run_abinit_kwargs=None):
8491
8592 yield _run
8693
87- mocker . stopall ()
94+ monkeypatch . undo ()
8895 _REF_PATHS .clear ()
8996 _FAKE_RUN_ABINIT_KWARGS .clear ()
9097
0 commit comments