From 9d95dec5ea92bdaab0c839548e808e5b18cd6fd9 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 13 Sep 2017 19:03:54 +0200 Subject: [PATCH] Handle standarddir.config() correctly on macOS With auto=False we should get ~/.qutebrowser --- qutebrowser/utils/standarddir.py | 15 ++++++--------- tests/unit/utils/test_standarddir.py | 6 +++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/qutebrowser/utils/standarddir.py b/qutebrowser/utils/standarddir.py index f230bb672..a6df75948 100644 --- a/qutebrowser/utils/standarddir.py +++ b/qutebrowser/utils/standarddir.py @@ -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] diff --git a/tests/unit/utils/test_standarddir.py b/tests/unit/utils/test_standarddir.py index 725dd9e73..a9b30750c 100644 --- a/tests/unit/utils/test_standarddir.py +++ b/tests/unit/utils/test_standarddir.py @@ -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