File tree Expand file tree Collapse file tree 2 files changed +16
-26
lines changed Expand file tree Collapse file tree 2 files changed +16
-26
lines changed Original file line number Diff line number Diff line change 19
19
20
20
import pytest
21
21
22
- from .test_environment import (with_environment ,
23
- DATA_KEY ,
24
- USER_KEY )
22
+ from .test_environment import with_environment , DATA_KEY , USER_KEY
25
23
26
24
27
- @pytest .fixture ()
25
+ @pytest .fixture
28
26
def with_nimd_env (request , with_environment ):
29
27
DATA_FUNCS = {}
30
28
DATA_FUNCS ['home_dir_func' ] = nibd .get_nipy_user_dir
31
29
DATA_FUNCS ['sys_dir_func' ] = nibd .get_nipy_system_dir
32
30
DATA_FUNCS ['path_func' ] = nibd .get_data_path
33
-
34
- def teardown_data_env ():
35
- nibd .get_nipy_user_dir = DATA_FUNCS ['home_dir_func' ]
36
- nibd .get_nipy_system_dir = DATA_FUNCS ['sys_dir_func' ]
37
- nibd .get_data_path = DATA_FUNCS ['path_func' ]
38
-
39
- request .addfinalizer (teardown_data_env )
31
+ yield
32
+ nibd .get_nipy_user_dir = DATA_FUNCS ['home_dir_func' ]
33
+ nibd .get_nipy_system_dir = DATA_FUNCS ['sys_dir_func' ]
34
+ nibd .get_data_path = DATA_FUNCS ['path_func' ]
40
35
41
36
42
37
def test_datasource ():
Original file line number Diff line number Diff line change 14
14
USER_KEY = 'NIPY_USER_DIR'
15
15
16
16
17
- @pytest .fixture ()
17
+ @pytest .fixture
18
18
def with_environment (request ):
19
19
"""Setup test environment for some functions that are tested
20
20
in this module. In particular this functions stores attributes
@@ -24,20 +24,15 @@ def with_environment(request):
24
24
"""
25
25
GIVEN_ENV = {}
26
26
GIVEN_ENV ['env' ] = env .copy ()
27
-
28
-
29
- def teardown_environment ():
30
- """Restore things that were remembered by the setup_environment function
31
- """
32
- orig_env = GIVEN_ENV ['env' ]
33
- # Pull keys out into list to avoid altering dictionary during iteration,
34
- # causing python 3 error
35
- for key in list (env .keys ()):
36
- if key not in orig_env :
37
- del env [key ]
38
- env .update (orig_env )
39
-
40
- request .addfinalizer (teardown_environment )
27
+ yield
28
+ """Restore things that were remembered by the setup_environment function """
29
+ orig_env = GIVEN_ENV ['env' ]
30
+ # Pull keys out into list to avoid altering dictionary during iteration,
31
+ # causing python 3 error
32
+ for key in list (env .keys ()):
33
+ if key not in orig_env :
34
+ del env [key ]
35
+ env .update (orig_env )
41
36
42
37
43
38
def test_nipy_home ():
You can’t perform that action at this time.
0 commit comments