def test_display_parse(monkeypatch, dispvar): """Check that when $DISPLAY is defined, the display is correctly parsed""" config._display = None config._config.remove_option('execution', 'display_variable') monkeypatch.setenv('DISPLAY', dispvar) assert config.get_display() == ':12' # Test that it was correctly cached assert config.get_display() == ':12'
def test_display_parse(monkeypatch, dispvar): """Check that when $DISPLAY is defined, the display is correctly parsed""" config._display = None config._config.remove_option("execution", "display_variable") monkeypatch.setenv("DISPLAY", dispvar) assert config.get_display() == ":12" # Test that it was correctly cached assert config.get_display() == ":12"
def test_display_system(monkeypatch, dispnum): """Check that when only a $DISPLAY is defined, it is used""" config._display = None config._config.remove_option('execution', 'display_variable') dispstr = ':%d' % dispnum monkeypatch.setenv('DISPLAY', dispstr) assert config.get_display() == dispstr # Test that it was correctly cached assert config.get_display() == dispstr
def test_display_config(monkeypatch, dispnum): """Check that the display_variable option is used ($DISPLAY not set)""" config._display = None dispstr = ':%d' % dispnum config.set('execution', 'display_variable', dispstr) monkeypatch.delitem(os.environ, 'DISPLAY', raising=False) assert config.get_display() == config.get('execution', 'display_variable') # Test that it was correctly cached assert config.get_display() == config.get('execution', 'display_variable')
def test_display_config_and_system(monkeypatch): """Check that when only both config and $DISPLAY are defined, the config takes precedence""" config._display = None dispstr = ':10' config.set('execution', 'display_variable', dispstr) monkeypatch.setitem(os.environ, 'DISPLAY', ':0') assert config.get_display() == dispstr # Test that it was correctly cached assert config.get_display() == dispstr
def test_display_config_and_system(monkeypatch): """Check that when only both config and $DISPLAY are defined, the config takes precedence""" config._display = None dispstr = ":10" config.set("execution", "display_variable", dispstr) monkeypatch.setenv("DISPLAY", ":0") assert config.get_display() == dispstr # Test that it was correctly cached assert config.get_display() == dispstr
def test_display_noconfig_nosystem_patched(monkeypatch): """Check that when no $DISPLAY nor option are specified, a virtual Xvfb is used""" config._display = None if config.has_option('execution', 'display_variable'): config._config.remove_option('execution', 'display_variable') monkeypatch.delitem(os.environ, 'DISPLAY', raising=False) monkeypatch.setitem(sys.modules, 'xvfbwrapper', xvfbpatch) assert config.get_display() == ":2010" # Test that it was correctly cached assert config.get_display() == ':2010'
def test_display_empty_notinstalled(monkeypatch): """ Check that an exception is raised if xvfbwrapper is not installed but necessary (no config and $DISPLAY empty) """ config._display = None if config.has_option('execution', 'display_variable'): config._config.remove_option('execution', 'display_variable') monkeypatch.setenv('DISPLAY', '') monkeypatch.setitem(sys.modules, 'xvfbwrapper', None) with pytest.raises(RuntimeError): config.get_display()
def test_display_noconfig_nosystem_notinstalled(monkeypatch): """ Check that an exception is raised if xvfbwrapper is not installed but necessary (no config and $DISPLAY unset) """ config._display = None if config.has_option("execution", "display_variable"): config._config.remove_option("execution", "display_variable") monkeypatch.delenv("DISPLAY", raising=False) monkeypatch.setitem(sys.modules, "xvfbwrapper", None) with pytest.raises(RuntimeError): config.get_display()
def test_display_empty_installed(monkeypatch): """ Check that actually uses xvfbwrapper when installed (not mocked) and necessary (no config and $DISPLAY empty) """ config._display = None if config.has_option('execution', 'display_variable'): config._config.remove_option('execution', 'display_variable') monkeypatch.setenv('DISPLAY', '') newdisp = config.get_display() assert int(newdisp.split(':')[-1]) > 1000 # Test that it was correctly cached assert config.get_display() == newdisp
def test_display_noconfig_nosystem_installed(monkeypatch): """ Check that actually uses xvfbwrapper when installed (not mocked) and necessary (no config and $DISPLAY unset) """ config._display = None if config.has_option("execution", "display_variable"): config._config.remove_option("execution", "display_variable") monkeypatch.delenv("DISPLAY", raising=False) newdisp = config.get_display() assert int(newdisp.split(":")[-1]) > 1000 # Test that it was correctly cached assert config.get_display() == newdisp
def test_display_empty_patched(monkeypatch): """ Check that when $DISPLAY is empty string and no option is specified, a virtual Xvfb is used """ config._display = None if config.has_option('execution', 'display_variable'): config._config.remove_option('execution', 'display_variable') monkeypatch.setitem(os.environ, 'DISPLAY', '') monkeypatch.setitem(sys.modules, 'xvfbwrapper', xvfbpatch) assert config.get_display() == ':2010' # Test that it was correctly cached assert config.get_display() == ':2010'
def test_display_noconfig_nosystem_installed(monkeypatch): """ Check that actually uses xvfbwrapper when installed (not mocked) and necessary (no config and $DISPLAY unset) """ config._display = None if config.has_option('execution', 'display_variable'): config._config.remove_option('execution', 'display_variable') monkeypatch.delitem(os.environ, 'DISPLAY', raising=False) newdisp = config.get_display() assert int(newdisp.split(':')[-1]) > 1000 # Test that it was correctly cached assert config.get_display() == newdisp
def test_display_empty_macosx(monkeypatch): """ Check that an exception is raised if xvfbwrapper is necessary (no config and $DISPLAY unset) but platform is OSX. See https://github.com/nipy/nipype/issues/1400 """ config._display = None if config.has_option('execution', 'display_variable'): config._config.remove_option('execution', 'display_variable') monkeypatch.delenv('DISPLAY', '') monkeypatch.setattr(sys, 'platform', 'darwin') with pytest.raises(RuntimeError): config.get_display()
def test_display_noconfig_nosystem_patched(monkeypatch): """Check that when no $DISPLAY nor option are specified, a virtual Xvfb is used""" config._display = None if config.has_option("execution", "display_variable"): config._config.remove_option("execution", "display_variable") monkeypatch.delitem(os.environ, "DISPLAY", raising=False) monkeypatch.setitem(sys.modules, "xvfbwrapper", xvfbpatch) monkeypatch.setattr(sys, "platform", value="linux") assert config.get_display() == ":2010" # Test that it was correctly cached assert config.get_display() == ":2010" # Check that raises in Mac config._display = None monkeypatch.setattr(sys, "platform", value="darwin") with pytest.raises(RuntimeError): config.get_display()
def test_display_noconfig_nosystem_patched(monkeypatch): """Check that when no $DISPLAY nor option are specified, a virtual Xvfb is used""" config._display = None if config.has_option('execution', 'display_variable'): config._config.remove_option('execution', 'display_variable') monkeypatch.delitem(os.environ, 'DISPLAY', raising=False) monkeypatch.setitem(sys.modules, 'xvfbwrapper', xvfbpatch) monkeypatch.setattr(sys, 'platform', value='linux') assert config.get_display() == ":2010" # Test that it was correctly cached assert config.get_display() == ':2010' # Check that raises in Mac config._display = None monkeypatch.setattr(sys, 'platform', value='darwin') with pytest.raises(RuntimeError): config.get_display()
def test_display_empty_patched(monkeypatch): """ Check that when $DISPLAY is empty string and no option is specified, a virtual Xvfb is used """ config._display = None if config.has_option('execution', 'display_variable'): config._config.remove_option('execution', 'display_variable') monkeypatch.setenv('DISPLAY', '') monkeypatch.setitem(sys.modules, 'xvfbwrapper', xvfbpatch) monkeypatch.setattr(sys, 'platform', value='linux') assert config.get_display() == ':2010' # Test that it was correctly cached assert config.get_display() == ':2010' # Check that raises in Mac config._display = None monkeypatch.setattr(sys, 'platform', value='darwin') with pytest.raises(RuntimeError): config.get_display()
def test_display_empty_patched(monkeypatch): """ Check that when $DISPLAY is empty string and no option is specified, a virtual Xvfb is used """ config._display = None if config.has_option("execution", "display_variable"): config._config.remove_option("execution", "display_variable") monkeypatch.setenv("DISPLAY", "") monkeypatch.setitem(sys.modules, "xvfbwrapper", xvfbpatch) monkeypatch.setattr(sys, "platform", value="linux") assert config.get_display() == ":2010" # Test that it was correctly cached assert config.get_display() == ":2010" # Check that raises in Mac config._display = None monkeypatch.setattr(sys, "platform", value="darwin") with pytest.raises(RuntimeError): config.get_display()