@@ -35,6 +35,8 @@ def test_display_config(monkeypatch, dispnum):
35
35
config .set ('execution' , 'display_variable' , dispstr )
36
36
monkeypatch .delitem (os .environ , 'DISPLAY' , raising = False )
37
37
assert config .get_display () == config .get ('execution' , 'display_variable' )
38
+ # Test that it was correctly cached
39
+ assert config .get_display () == config .get ('execution' , 'display_variable' )
38
40
39
41
40
42
@pytest .mark .parametrize ('dispnum' , range (5 ))
@@ -45,6 +47,8 @@ def test_display_system(monkeypatch, dispnum):
45
47
dispstr = ':%d' % dispnum
46
48
monkeypatch .setitem (os .environ , 'DISPLAY' , dispstr )
47
49
assert config .get_display () == dispstr
50
+ # Test that it was correctly cached
51
+ assert config .get_display () == dispstr
48
52
49
53
50
54
def test_display_config_and_system (monkeypatch ):
@@ -54,6 +58,8 @@ def test_display_config_and_system(monkeypatch):
54
58
config .set ('execution' , 'display_variable' , dispstr )
55
59
monkeypatch .setitem (os .environ , 'DISPLAY' , ':0' )
56
60
assert config .get_display () == dispstr
61
+ # Test that it was correctly cached
62
+ assert config .get_display () == dispstr
57
63
58
64
59
65
def test_display_noconfig_nosystem_patched (monkeypatch ):
@@ -64,6 +70,8 @@ def test_display_noconfig_nosystem_patched(monkeypatch):
64
70
monkeypatch .delitem (os .environ , 'DISPLAY' , raising = False )
65
71
monkeypatch .setitem (sys .modules , 'xvfbwrapper' , xvfbpatch )
66
72
assert config .get_display () == ":2010"
73
+ # Test that it was correctly cached
74
+ assert config .get_display () == ':2010'
67
75
68
76
69
77
def test_display_empty_patched (monkeypatch ):
@@ -77,6 +85,8 @@ def test_display_empty_patched(monkeypatch):
77
85
monkeypatch .setitem (os .environ , 'DISPLAY' , '' )
78
86
monkeypatch .setitem (sys .modules , 'xvfbwrapper' , xvfbpatch )
79
87
assert config .get_display () == ':2010'
88
+ # Test that it was correctly cached
89
+ assert config .get_display () == ':2010'
80
90
81
91
82
92
def test_display_noconfig_nosystem_patched_oldxvfbwrapper (monkeypatch ):
@@ -90,6 +100,8 @@ def test_display_noconfig_nosystem_patched_oldxvfbwrapper(monkeypatch):
90
100
monkeypatch .delitem (os .environ , 'DISPLAY' , raising = False )
91
101
monkeypatch .setitem (sys .modules , 'xvfbwrapper' , xvfbpatch_old )
92
102
assert config .get_display () == ":2010"
103
+ # Test that it was correctly cached
104
+ assert config .get_display () == ':2010'
93
105
94
106
95
107
def test_display_empty_patched_oldxvfbwrapper (monkeypatch ):
@@ -103,6 +115,8 @@ def test_display_empty_patched_oldxvfbwrapper(monkeypatch):
103
115
monkeypatch .setitem (os .environ , 'DISPLAY' , '' )
104
116
monkeypatch .setitem (sys .modules , 'xvfbwrapper' , xvfbpatch_old )
105
117
assert config .get_display () == ':2010'
118
+ # Test that it was correctly cached
119
+ assert config .get_display () == ':2010'
106
120
107
121
108
122
def test_display_noconfig_nosystem_notinstalled (monkeypatch ):
@@ -143,7 +157,10 @@ def test_display_noconfig_nosystem_installed(monkeypatch):
143
157
if config .has_option ('execution' , 'display_variable' ):
144
158
config ._config .remove_option ('execution' , 'display_variable' )
145
159
monkeypatch .delitem (os .environ , 'DISPLAY' , raising = False )
146
- assert int (config .get_display ().split (':' )[- 1 ]) > 1000
160
+ newdisp = config .get_display ()
161
+ assert int (newdisp .split (':' )[- 1 ]) > 1000
162
+ # Test that it was correctly cached
163
+ assert config .get_display () == newdisp
147
164
148
165
149
166
@pytest .mark .skipif (not has_Xvfb , reason = 'xvfbwrapper not installed' )
@@ -156,7 +173,10 @@ def test_display_empty_installed(monkeypatch):
156
173
if config .has_option ('execution' , 'display_variable' ):
157
174
config ._config .remove_option ('execution' , 'display_variable' )
158
175
monkeypatch .setitem (os .environ , 'DISPLAY' , '' )
159
- assert int (config .get_display ().split (':' )[- 1 ]) > 1000
176
+ newdisp = config .get_display ()
177
+ assert int (newdisp .split (':' )[- 1 ]) > 1000
178
+ # Test that it was correctly cached
179
+ assert config .get_display () == newdisp
160
180
161
181
162
182
def test_display_empty_macosx (monkeypatch ):
0 commit comments