Skip to content

Commit 4dc5896

Browse files
committed
use mokeypatch.setenv
1 parent fbac4ee commit 4dc5896

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

nipype/utils/tests/test_config.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_display_parse(monkeypatch, disp_var):
3232
"""Check that when $DISPLAY is defined, the display is correctly parsed"""
3333
config._display = None
3434
dispstr = ':0'
35-
monkeypatch.setitem(os.environ, 'DISPLAY', disp_var)
35+
monkeypatch.setenv('DISPLAY', disp_var)
3636
assert config.get_display() == dispstr
3737
# Test that it was correctly cached
3838
assert config.get_display() == dispstr
@@ -56,7 +56,7 @@ def test_display_system(monkeypatch, dispnum):
5656
config._display = None
5757
config._config.remove_option('execution', 'display_variable')
5858
dispstr = ':%d' % dispnum
59-
monkeypatch.setitem(os.environ, 'DISPLAY', dispstr)
59+
monkeypatch.setenv('DISPLAY', dispstr)
6060
assert config.get_display() == dispstr
6161
# Test that it was correctly cached
6262
assert config.get_display() == dispstr
@@ -67,7 +67,7 @@ def test_display_config_and_system(monkeypatch):
6767
config._display = None
6868
dispstr = ':10'
6969
config.set('execution', 'display_variable', dispstr)
70-
monkeypatch.setitem(os.environ, 'DISPLAY', ':0')
70+
monkeypatch.setenv('DISPLAY', ':0')
7171
assert config.get_display() == dispstr
7272
# Test that it was correctly cached
7373
assert config.get_display() == dispstr
@@ -93,7 +93,7 @@ def test_display_empty_patched(monkeypatch):
9393
config._display = None
9494
if config.has_option('execution', 'display_variable'):
9595
config._config.remove_option('execution', 'display_variable')
96-
monkeypatch.setitem(os.environ, 'DISPLAY', '')
96+
monkeypatch.setenv('DISPLAY', '')
9797
monkeypatch.setitem(sys.modules, 'xvfbwrapper', xvfbpatch)
9898
assert config.get_display() == ':2010'
9999
# Test that it was correctly cached
@@ -123,7 +123,7 @@ def test_display_empty_patched_oldxvfbwrapper(monkeypatch):
123123
config._display = None
124124
if config.has_option('execution', 'display_variable'):
125125
config._config.remove_option('execution', 'display_variable')
126-
monkeypatch.setitem(os.environ, 'DISPLAY', '')
126+
monkeypatch.setenv('DISPLAY', '')
127127
monkeypatch.setitem(sys.modules, 'xvfbwrapper', xvfbpatch_old)
128128
assert config.get_display() == ':2010'
129129
# Test that it was correctly cached
@@ -152,7 +152,7 @@ def test_display_empty_notinstalled(monkeypatch):
152152
config._display = None
153153
if config.has_option('execution', 'display_variable'):
154154
config._config.remove_option('execution', 'display_variable')
155-
monkeypatch.setitem(os.environ, 'DISPLAY', '')
155+
monkeypatch.setenv('DISPLAY', '')
156156
monkeypatch.setitem(sys.modules, 'xvfbwrapper', None)
157157
with pytest.raises(RuntimeError):
158158
config.get_display()
@@ -183,7 +183,7 @@ def test_display_empty_installed(monkeypatch):
183183
config._display = None
184184
if config.has_option('execution', 'display_variable'):
185185
config._config.remove_option('execution', 'display_variable')
186-
monkeypatch.setitem(os.environ, 'DISPLAY', '')
186+
monkeypatch.setenv('DISPLAY', '')
187187
newdisp = config.get_display()
188188
assert int(newdisp.split(':')[-1]) > 1000
189189
# Test that it was correctly cached

0 commit comments

Comments
 (0)