Include expandvars in File.transform, adjust test
This commit is contained in:
parent
cfae36c5c8
commit
e12dce9d55
@ -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:
|
||||
|
@ -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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user