nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
745 stars 529 forks source link

test_Commandline_environ fails if ran on a system with DISPLAY set #2836

Open yarikoptic opened 5 years ago

yarikoptic commented 5 years ago

testing 1.1.7 as "system wide installed" on a debian system (sorry for a wide display) lead to

____________________________________________________________________________________________________________________________________________ test_Commandline_environ ____________________________________________________________________________________________________________________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f60b31ea390>, tmpdir = local('/home/yoh/.tmp/pytest-of-yoh/pytest-24/test_Commandline_environ0')

    def test_Commandline_environ(monkeypatch, tmpdir):
        from nipype import config
        config.set_default_config()

        tmpdir.chdir()
        monkeypatch.setitem(os.environ, 'DISPLAY', ':1')
        # Test environment
        ci3 = nib.CommandLine(command='echo')
        res = ci3.run()
        assert res.runtime.environ['DISPLAY'] == ':1'

        # Test display_variable option
        monkeypatch.delitem(os.environ, 'DISPLAY', raising=False)
        config.set('execution', 'display_variable', ':3')
        res = ci3.run()
        assert 'DISPLAY' not in ci3.inputs.environ
        assert 'DISPLAY' not in res.runtime.environ

        # If the interface has _redirect_x then yes, it should be set
        ci3._redirect_x = True
        res = ci3.run()
>       assert res.runtime.environ['DISPLAY'] == ':3'
E       AssertionError: assert ':0' == ':3'
E         - :0
E         + :3

I do indeed have :0 DISPLAY currently (that is why probably didn't observe failure while building the package in an env without DISPLAY)

oesteban commented 5 years ago

I wonder why the monkeypatch.delitem(os.environ, 'DISPLAY', raising=False) line seems to make no effect on your case.