Handle standarddir.config() correctly on macOS

With auto=False we should get ~/.qutebrowser
This commit is contained in:
Florian Bruhin 2017-09-13 19:03:54 +02:00
parent 08b5fc8e3b
commit 9d95dec5ea
2 changed files with 9 additions and 12 deletions

View File

@ -60,15 +60,15 @@ def _init_config(args):
path = os.path.join(path, appname)
_create(path)
_locations[Location.config] = path
_locations[Location.auto_config] = path
# auto config
# Override the normal (non-auto) config on macOS
if sys.platform == 'darwin':
overridden, path = _from_args(typ, args)
_locations.pop(Location.auto_config, None) # Remove old state
if not overridden:
if not overridden: # pragma: no branch
path = os.path.expanduser('~/.qutebrowser')
_create(path)
_locations[Location.auto_config] = path
_create(path)
_locations[Location.config] = path
def config(auto=False):
@ -78,10 +78,7 @@ def config(auto=False):
which is different on macOS.
"""
if auto:
try:
return _locations[Location.auto_config]
except KeyError:
pass
return _locations[Location.auto_config]
return _locations[Location.config]

View File

@ -44,13 +44,13 @@ def clear_standarddir_cache(monkeypatch):
monkeypatch.setattr(standarddir, '_locations', {})
def test_fake_mac_auto_config(tmpdir, monkeypatch):
"""Test standardir.config(auto=True) on a fake Mac."""
def test_fake_mac_config(tmpdir, monkeypatch):
"""Test standardir.config on a fake Mac."""
monkeypatch.setattr(sys, 'platform', 'darwin')
monkeypatch.setenv('HOME', str(tmpdir))
expected = str(tmpdir) + '/.qutebrowser' # always with /
standarddir._init_config(args=None)
assert standarddir.config(auto=True) == expected
assert standarddir.config() == expected
# FIXME:conf