Fix standarddir.cache() on Windows

This commit is contained in:
Florian Bruhin 2017-09-17 09:44:34 +02:00
parent b31db0d0d5
commit 7ed64efa08
2 changed files with 12 additions and 4 deletions

View File

@ -120,7 +120,12 @@ def _init_cache(args):
typ = QStandardPaths.CacheLocation
overridden, path = _from_args(typ, args)
if not overridden:
path = _writable_location(typ)
if os.name == 'nt':
# Local, not Roaming!
data_path = _writable_location(QStandardPaths.DataLocation)
path = os.path.join(data_path, 'cache')
else:
path = _writable_location(typ)
_create(path)
_locations[Location.cache] = path

View File

@ -67,15 +67,18 @@ def test_fake_mac_config(tmpdir, monkeypatch):
# FIXME:conf needs AppDataLocation
@pytest.mark.qt55
@pytest.mark.parametrize('what', ['data', 'config'])
@pytest.mark.parametrize('what', ['data', 'config', 'cache'])
@pytest.mark.not_mac
def test_fake_windows_data_config(tmpdir, monkeypatch, what):
"""Make sure the config is correct on a fake Windows."""
def test_fake_windows(tmpdir, monkeypatch, what):
"""Make sure the config/data/cache dirs are correct on a fake Windows."""
monkeypatch.setattr(os, 'name', 'nt')
monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
lambda typ: str(tmpdir / APPNAME))
standarddir._init_config(args=None)
standarddir._init_data(args=None)
standarddir._init_cache(args=None)
func = getattr(standarddir, what)
assert func() == str(tmpdir / APPNAME / what)