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():
202202 Xvfb = namedtuple ('Xvfb' , ['vdisplay_num' , 'stop' ])
203203 self ._display = Xvfb (ndisp , _mock )
204204 return sysdisplay
205-
206205 else :
206+ # If $DISPLAY is empty, it confuses Xvfb so unset
207+ if sysdisplay == '' :
208+ del os .environ ['DISPLAY' ]
207209 try :
208210 from xvfbwrapper import Xvfb
209211 except ImportError :
210212 raise RuntimeError (
211213 'A display server was required, but $DISPLAY is not defined '
212- ' and Xvfb could not be imported.' )
214+ 'and Xvfb could not be imported.' )
213215
214216 self ._display = Xvfb (nolisten = 'tcp' )
215217 self ._display .start ()
Original file line number Diff line number Diff line change @@ -38,4 +38,12 @@ def test_display_noconfig_nosystem(monkeypatch):
3838 if config .has_option ('execution' , 'display_variable' ):
3939 config ._config .remove_option ('execution' , 'display_variable' )
4040 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