Make standarddir work on HaikuOS
For some reason, it returns an empty DataLocation.
This commit is contained in:
parent
828ffd4979
commit
9dc9bcaf39
@ -20,6 +20,7 @@
|
||||
"""Utilities to get and initialize data/config paths."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import os.path
|
||||
import contextlib
|
||||
@ -106,6 +107,10 @@ def _init_data(args):
|
||||
if utils.is_windows:
|
||||
app_data_path = _writable_location(QStandardPaths.AppDataLocation)
|
||||
path = os.path.join(app_data_path, 'data')
|
||||
elif sys.platform.startswith('haiku'):
|
||||
# HaikuOS returns an empty value for AppDataLocation
|
||||
config_path = _writable_location(QStandardPaths.ConfigLocation)
|
||||
path = os.path.join(config_path, 'data')
|
||||
else:
|
||||
path = _writable_location(typ)
|
||||
_create(path)
|
||||
|
@ -103,6 +103,20 @@ def test_fake_windows(tmpdir, monkeypatch, what):
|
||||
assert func() == str(tmpdir / APPNAME / what)
|
||||
|
||||
|
||||
def test_fake_haiku(tmpdir, monkeypatch):
|
||||
"""Test getting data dir on HaikuOS."""
|
||||
locations = {
|
||||
QStandardPaths.DataLocation: '',
|
||||
QStandardPaths.ConfigLocation: str(tmpdir / 'config' / APPNAME),
|
||||
}
|
||||
monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
|
||||
locations.get)
|
||||
monkeypatch.setattr(standarddir.sys, 'platform', 'haiku1')
|
||||
|
||||
standarddir._init_data(args=None)
|
||||
assert standarddir.data() == str(tmpdir / 'config' / APPNAME / 'data')
|
||||
|
||||
|
||||
class TestWritableLocation:
|
||||
|
||||
"""Tests for _writable_location."""
|
||||
|
Loading…
Reference in New Issue
Block a user