From e12dce9d55eb3d1d3aeb56691e1b10fa28c5d506 Mon Sep 17 00:00:00 2001 From: Lamar Pavel Date: Wed, 27 May 2015 14:40:07 +0200 Subject: [PATCH] Include expandvars in File.transform, adjust test --- qutebrowser/config/configtypes.py | 8 +++----- tests/config/test_configtypes.py | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index 4b0b5b70f..626ec43c2 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -803,6 +803,7 @@ class File(BaseType): if not value: return None value = os.path.expanduser(value) + value = os.path.expandvars(value) if not os.path.isabs(value): if standarddir.config(): abspath = os.path.join(standarddir.config(), value) @@ -818,10 +819,8 @@ class File(BaseType): raise configexc.ValidationError(value, "may not be empty!") value = os.path.expanduser(value) try: - if not os.path.isabs(value): - abspath = os.path.join(standarddir.config(), value) - if os.path.isfile(abspath): - return + if os.path.isfile(os.path.join(standarddir.config(), value)): + return if not os.path.isfile(value): raise configexc.ValidationError(value, "must be a valid file!") if not os.path.isabs(value): @@ -1166,7 +1165,6 @@ class UserStyleSheet(File): if not value: return None path = super().transform(value) - path = os.path.expandvars(path) if os.path.isabs(path): return QUrl.fromLocalFile(path) else: diff --git a/tests/config/test_configtypes.py b/tests/config/test_configtypes.py index d8af6995d..c7df07f14 100644 --- a/tests/config/test_configtypes.py +++ b/tests/config/test_configtypes.py @@ -1398,6 +1398,7 @@ class TestFile: def test_transform(self, os_path): """Test transform.""" os_path.expanduser.side_effect = lambda x: x.replace('~', '/home/foo') + os_path.expandvars.side_effect = lambda x: x assert self.t.transform('~/foobar') == '/home/foo/foobar' os_path.expanduser.assert_called_once_with('~/foobar')