Split up _init_envvars from configinit.early_init
This commit is contained in:
parent
f63b95c298
commit
0e64511d63
@ -76,6 +76,11 @@ def early_init(args):
|
|||||||
except configexc.Error as e:
|
except configexc.Error as e:
|
||||||
message.error("set: {} - {}".format(e.__class__.__name__, e))
|
message.error("set: {} - {}".format(e.__class__.__name__, e))
|
||||||
|
|
||||||
|
_init_envvars()
|
||||||
|
|
||||||
|
|
||||||
|
def _init_envvars():
|
||||||
|
"""Initialize environment variables which need to be set early."""
|
||||||
if (objects.backend == usertypes.Backend.QtWebEngine and
|
if (objects.backend == usertypes.Backend.QtWebEngine and
|
||||||
config.val.force_software_rendering):
|
config.val.force_software_rendering):
|
||||||
os.environ['QT_XCB_FORCE_SOFTWARE_OPENGL'] = '1'
|
os.environ['QT_XCB_FORCE_SOFTWARE_OPENGL'] = '1'
|
||||||
|
@ -196,22 +196,22 @@ class TestEarlyInit:
|
|||||||
assert msg.text == "set: NoOptionError - No option 'foo'"
|
assert msg.text == "set: NoOptionError - No option 'foo'"
|
||||||
assert 'colors.completion.fg' not in config.instance._values
|
assert 'colors.completion.fg' not in config.instance._values
|
||||||
|
|
||||||
def test_force_software_rendering(self, monkeypatch, init_patch, args):
|
def test_force_software_rendering(self, monkeypatch, config_stub):
|
||||||
"""Setting force_software_rendering should set the environment var."""
|
"""Setting force_software_rendering should set the environment var."""
|
||||||
envvar = 'QT_XCB_FORCE_SOFTWARE_OPENGL'
|
envvar = 'QT_XCB_FORCE_SOFTWARE_OPENGL'
|
||||||
monkeypatch.setattr(configinit.objects, 'backend',
|
monkeypatch.setattr(configinit.objects, 'backend',
|
||||||
usertypes.Backend.QtWebEngine)
|
usertypes.Backend.QtWebEngine)
|
||||||
monkeypatch.delenv(envvar, raising=False)
|
monkeypatch.delenv(envvar, raising=False)
|
||||||
args.temp_settings = [('force_software_rendering', 'true')]
|
|
||||||
args.backend = 'webengine'
|
|
||||||
|
|
||||||
configinit.early_init(args)
|
config_stub.val.force_software_rendering = True
|
||||||
|
|
||||||
|
configinit._init_envvars()
|
||||||
|
|
||||||
assert os.environ[envvar] == '1'
|
assert os.environ[envvar] == '1'
|
||||||
|
|
||||||
@pytest.mark.parametrize('old', ['1', '0', None])
|
@pytest.mark.parametrize('old', ['1', '0', None])
|
||||||
@pytest.mark.parametrize('configval', [True, False])
|
@pytest.mark.parametrize('configval', [True, False])
|
||||||
def test_hide_wayland_decoration(self, monkeypatch, init_patch, args,
|
def test_hide_wayland_decoration(self, monkeypatch, config_stub,
|
||||||
old, configval):
|
old, configval):
|
||||||
envvar = 'QT_WAYLAND_DISABLE_WINDOWDECORATION'
|
envvar = 'QT_WAYLAND_DISABLE_WINDOWDECORATION'
|
||||||
if old is None:
|
if old is None:
|
||||||
@ -219,12 +219,10 @@ class TestEarlyInit:
|
|||||||
else:
|
else:
|
||||||
monkeypatch.setenv(envvar, old)
|
monkeypatch.setenv(envvar, old)
|
||||||
|
|
||||||
args.temp_settings = [('window.hide_wayland_decoration',
|
config_stub.val.window.hide_wayland_decoration = configval
|
||||||
str(configval))]
|
configinit._init_envvars()
|
||||||
configinit.early_init(args)
|
|
||||||
|
|
||||||
expected = '1' if configval else None
|
assert os.environ.get(envvar) == ('1' if configval else None)
|
||||||
assert os.environ.get(envvar) == expected
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('errors', [True, False])
|
@pytest.mark.parametrize('errors', [True, False])
|
||||||
|
Loading…
Reference in New Issue
Block a user