Handle standarddir.config() correctly on macOS
With auto=False we should get ~/.qutebrowser
This commit is contained in:
parent
08b5fc8e3b
commit
9d95dec5ea
@ -60,15 +60,15 @@ def _init_config(args):
|
|||||||
path = os.path.join(path, appname)
|
path = os.path.join(path, appname)
|
||||||
_create(path)
|
_create(path)
|
||||||
_locations[Location.config] = path
|
_locations[Location.config] = path
|
||||||
|
_locations[Location.auto_config] = path
|
||||||
|
|
||||||
# auto config
|
# Override the normal (non-auto) config on macOS
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
overridden, path = _from_args(typ, args)
|
overridden, path = _from_args(typ, args)
|
||||||
_locations.pop(Location.auto_config, None) # Remove old state
|
if not overridden: # pragma: no branch
|
||||||
if not overridden:
|
|
||||||
path = os.path.expanduser('~/.qutebrowser')
|
path = os.path.expanduser('~/.qutebrowser')
|
||||||
_create(path)
|
_create(path)
|
||||||
_locations[Location.auto_config] = path
|
_locations[Location.config] = path
|
||||||
|
|
||||||
|
|
||||||
def config(auto=False):
|
def config(auto=False):
|
||||||
@ -78,10 +78,7 @@ def config(auto=False):
|
|||||||
which is different on macOS.
|
which is different on macOS.
|
||||||
"""
|
"""
|
||||||
if auto:
|
if auto:
|
||||||
try:
|
return _locations[Location.auto_config]
|
||||||
return _locations[Location.auto_config]
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
return _locations[Location.config]
|
return _locations[Location.config]
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,13 +44,13 @@ def clear_standarddir_cache(monkeypatch):
|
|||||||
monkeypatch.setattr(standarddir, '_locations', {})
|
monkeypatch.setattr(standarddir, '_locations', {})
|
||||||
|
|
||||||
|
|
||||||
def test_fake_mac_auto_config(tmpdir, monkeypatch):
|
def test_fake_mac_config(tmpdir, monkeypatch):
|
||||||
"""Test standardir.config(auto=True) on a fake Mac."""
|
"""Test standardir.config on a fake Mac."""
|
||||||
monkeypatch.setattr(sys, 'platform', 'darwin')
|
monkeypatch.setattr(sys, 'platform', 'darwin')
|
||||||
monkeypatch.setenv('HOME', str(tmpdir))
|
monkeypatch.setenv('HOME', str(tmpdir))
|
||||||
expected = str(tmpdir) + '/.qutebrowser' # always with /
|
expected = str(tmpdir) + '/.qutebrowser' # always with /
|
||||||
standarddir._init_config(args=None)
|
standarddir._init_config(args=None)
|
||||||
assert standarddir.config(auto=True) == expected
|
assert standarddir.config() == expected
|
||||||
|
|
||||||
|
|
||||||
# FIXME:conf
|
# FIXME:conf
|
||||||
|
Loading…
Reference in New Issue
Block a user