flatpak: Fix standarddir/ipc tests

(cherry picked from commit f35e284de0)
This commit is contained in:
Florian Bruhin 2021-03-30 21:27:16 +02:00
parent 0a4cb0ef7f
commit d7913f78f6
2 changed files with 22 additions and 2 deletions

View File

@ -36,7 +36,7 @@ from PyQt5.QtTest import QSignalSpy
import qutebrowser
from qutebrowser.misc import ipc
from qutebrowser.utils import standarddir, utils
from qutebrowser.utils import standarddir, utils, version
from helpers import stubs, testutils
@ -219,6 +219,7 @@ class TestSocketName:
assert parts[-1] == expected
@pytest.mark.linux
@pytest.mark.not_flatpak
@pytest.mark.parametrize('basedir, expected', [
(None, 'ipc-{}'.format(md5('testusername'))),
('/x', 'ipc-{}'.format(md5('testusername-/x'))),
@ -228,6 +229,20 @@ class TestSocketName:
expected_path = str(fake_runtime_dir / 'qutebrowser' / expected)
assert socketname == expected_path
# We can't use the fake_flatpak fixture here, because it conflicts with
# fake_runtime_dir...
@pytest.mark.linux
@pytest.mark.parametrize('basedir, expected', [
(None, 'ipc-{}'.format(md5('testusername'))),
('/x', 'ipc-{}'.format(md5('testusername-/x'))),
])
@pytest.mark.skipif(not version.is_flatpak(), reason="Needs Flatpak")
def test_flatpak(self, basedir, fake_runtime_dir, expected):
socketname = ipc._get_socketname(basedir)
expected_path = str(
fake_runtime_dir / 'app' / 'org.qutebrowser.qutebrowser' / expected)
assert socketname == expected_path
def test_other_unix(self):
"""Fake test for POSIX systems which aren't Linux/macOS.

View File

@ -155,7 +155,12 @@ class TestStandardDir:
(lambda: standarddir.config(auto=True),
standarddir._init_config, 'XDG_CONFIG_HOME'),
(standarddir.cache, standarddir._init_cache, 'XDG_CACHE_HOME'),
(standarddir.runtime, standarddir._init_runtime, 'XDG_RUNTIME_DIR'),
pytest.param(
standarddir.runtime,
standarddir._init_runtime,
'XDG_RUNTIME_DIR',
marks=pytest.mark.not_flatpak,
),
])
@pytest.mark.linux
def test_linux_explicit(self, monkeypatch, tmpdir,