Example #1
0
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'
Example #2
0
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()
Example #4
0
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
Example #6
0
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'
Example #7
0
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
Example #8
0
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()
Example #9
0
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()
Example #11
0
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()