File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -202,14 +202,16 @@ def _mock():
202
202
Xvfb = namedtuple ('Xvfb' , ['vdisplay_num' , 'stop' ])
203
203
self ._display = Xvfb (ndisp , _mock )
204
204
return sysdisplay
205
-
206
205
else :
206
+ # If $DISPLAY is empty, it confuses Xvfb so unset
207
+ if sysdisplay == '' :
208
+ del os .environ ['DISPLAY' ]
207
209
try :
208
210
from xvfbwrapper import Xvfb
209
211
except ImportError :
210
212
raise RuntimeError (
211
213
'A display server was required, but $DISPLAY is not defined '
212
- ' and Xvfb could not be imported.' )
214
+ 'and Xvfb could not be imported.' )
213
215
214
216
self ._display = Xvfb (nolisten = 'tcp' )
215
217
self ._display .start ()
Original file line number Diff line number Diff line change @@ -38,4 +38,12 @@ def test_display_noconfig_nosystem(monkeypatch):
38
38
if config .has_option ('execution' , 'display_variable' ):
39
39
config ._config .remove_option ('execution' , 'display_variable' )
40
40
monkeypatch .delitem (os .environ , 'DISPLAY' , raising = False )
41
- assert int (config .get_display ().split (':' )[- 1 ]) > 80
41
+ assert int (config .get_display ().split (':' )[- 1 ]) > 80
42
+
43
+ def test_display_empty (monkeypatch ):
44
+ """Check that when no display is specified, a virtual Xvfb is used"""
45
+ config ._display = None
46
+ if config .has_option ('execution' , 'display_variable' ):
47
+ config ._config .remove_option ('execution' , 'display_variable' )
48
+ monkeypatch .setitem (os .environ , 'DISPLAY' , '' )
49
+ assert int (config .get_display ().split (':' )[- 1 ]) > 80
You can’t perform that action at this time.
0 commit comments