@@ -58,13 +58,20 @@ def test_conf_init(monkeypatch, tmp_path, use_datalad):
5858
5959
6060@pytest .mark .parametrize ('use_datalad' , ['on' , 'off' ])
61- def test_setup_home (monkeypatch , tmp_path , capfd , use_datalad ):
61+ def test_setup_home (monkeypatch , tmp_path , capsys , use_datalad ):
6262 """Check the correct functioning of the installation hook."""
63+
64+ use_pre = tfc ._env_to_bool ('TEMPLATEFLOW_USE_DATALAD' , False )
65+
6366 home = (tmp_path / f'setup-home-{ use_datalad } ' ).absolute ()
6467 monkeypatch .setenv ('TEMPLATEFLOW_USE_DATALAD' , use_datalad )
6568 monkeypatch .setenv ('TEMPLATEFLOW_HOME' , str (home ))
6669
67- with capfd .disabled ():
70+ use_post = tfc ._env_to_bool ('TEMPLATEFLOW_USE_DATALAD' , False )
71+ assert use_post is (use_datalad == 'on' )
72+
73+ tfc ._preload ()
74+ with capsys .disabled ():
6875 reload (tfc )
6976
7077 # Ensure mocks are up-to-date
@@ -74,14 +81,14 @@ def test_setup_home(monkeypatch, tmp_path, capfd, use_datalad):
7481 assert tfc .TF_CACHED is False
7582 assert tfc .setup_home () is False
7683
77- out = capfd .readouterr ().out
84+ out = capsys .readouterr ().out
7885 assert _find_message (out , 'TemplateFlow was not cached' )
7986 assert ('TEMPLATEFLOW_HOME=%s' % home ) in out
8087 assert home .exists ()
8188 assert len (list (home .iterdir ())) > 0
8289
8390 updated = tfc .setup_home (force = True ) # Templateflow is now cached
84- out = capfd .readouterr ()[0 ]
91+ out = capsys .readouterr ()[0 ]
8592 assert _find_message (out , 'TemplateFlow was not cached' ) is False
8693
8794 if use_datalad == 'on' :
@@ -96,14 +103,14 @@ def test_setup_home(monkeypatch, tmp_path, capfd, use_datalad):
96103 # Let's force an update
97104 rmtree (str (home / 'tpl-MNI152NLin2009cAsym' ))
98105 updated = tfc .setup_home (force = True )
99- out = capfd .readouterr ()[0 ]
106+ out = capsys .readouterr ()[0 ]
100107 assert updated is True
101108 assert _find_message (out , 'Updating TEMPLATEFLOW_HOME using S3.' )
102109
103110 reload (tfc )
104111 assert tfc .TF_CACHED is True
105112 updated = tfc .setup_home () # Templateflow is now cached
106- out = capfd .readouterr ()[0 ]
113+ out = capsys .readouterr ()[0 ]
107114 assert not _find_message (out , 'TemplateFlow was not cached' )
108115
109116 if use_datalad == 'on' :
@@ -118,7 +125,7 @@ def test_setup_home(monkeypatch, tmp_path, capfd, use_datalad):
118125 # Let's force an update
119126 rmtree (str (home / 'tpl-MNI152NLin2009cAsym' ))
120127 updated = tfc .setup_home ()
121- out = capfd .readouterr ()[0 ]
128+ out = capsys .readouterr ()[0 ]
122129 assert updated is True
123130 assert _find_message (out , 'Updating TEMPLATEFLOW_HOME using S3.' )
124131
0 commit comments