summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-03-30 21:20:29 +0200
committerFlorian Bruhin <me@the-compiler.org>2021-03-31 13:10:09 +0200
commit952402066dda29bf638ddc9f109b5b163151cf72 (patch)
tree37a4a3c197caa513f8b1d22a681e43fc9af0e46c /tests
parent545a295cf0fc318538a2355f1244cfd2df575af9 (diff)
downloadqutebrowser-952402066dda29bf638ddc9f109b5b163151cf72.tar.gz
qutebrowser-952402066dda29bf638ddc9f109b5b163151cf72.zip
tests: Move flatpak patch to conftest
Diffstat (limited to 'tests')
-rw-r--r--tests/helpers/fixtures.py17
-rw-r--r--tests/unit/utils/test_standarddir.py9
-rw-r--r--tests/unit/utils/test_utils.py21
3 files changed, 24 insertions, 23 deletions
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py
index 89386a1a5..43959f246 100644
--- a/tests/helpers/fixtures.py
+++ b/tests/helpers/fixtures.py
@@ -748,3 +748,20 @@ def freezer(request, monkeypatch):
# Want to test unfrozen tests, but we are frozen
pytest.skip("Can't run with sys.frozen = True!")
return request.param
+
+
+@pytest.fixture
+def fake_flatpak(monkeypatch):
+ info = version.DistributionInfo(
+ id='org.kde.Platform',
+ parsed=version.Distribution.kde_flatpak,
+ version=utils.VersionNumber.parse('5.12'),
+ pretty='Unknown')
+
+ if not version.is_flatpak():
+ monkeypatch.setattr(version, 'distribution', lambda: info)
+
+ app_id = 'org.qutebrowser.qutebrowser'
+ monkeypatch.setenv('FLATPAK_ID', app_id)
+
+ assert version.is_flatpak()
diff --git a/tests/unit/utils/test_standarddir.py b/tests/unit/utils/test_standarddir.py
index fac015fb3..e2b850c33 100644
--- a/tests/unit/utils/test_standarddir.py
+++ b/tests/unit/utils/test_standarddir.py
@@ -204,23 +204,20 @@ class TestStandardDir:
@pytest.mark.linux
@pytest.mark.parametrize('args_basedir', [True, False])
- def test_flatpak_runtimedir(self, monkeypatch, tmp_path, args_basedir):
+ def test_flatpak_runtimedir(self, fake_flatpak, monkeypatch, tmp_path,
+ args_basedir):
runtime_path = tmp_path / 'runtime'
runtime_path.mkdir()
runtime_path.chmod(0o0700)
- app_id = 'org.qutebrowser.qutebrowser'
-
- monkeypatch.setattr(standarddir.version, 'is_flatpak', lambda: True)
monkeypatch.setenv('XDG_RUNTIME_DIR', str(runtime_path))
- monkeypatch.setenv('FLATPAK_ID', app_id)
if args_basedir:
init_args = types.SimpleNamespace(basedir=str(tmp_path))
expected = tmp_path / 'runtime'
else:
init_args = None
- expected = runtime_path / 'app' / app_id
+ expected = runtime_path / 'app' / 'org.qutebrowser.qutebrowser'
standarddir._init_runtime(args=init_args)
assert standarddir.runtime() == str(expected)
diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py
index 9622fe2eb..734758957 100644
--- a/tests/unit/utils/test_utils.py
+++ b/tests/unit/utils/test_utils.py
@@ -39,7 +39,7 @@ import yaml
import qutebrowser
import qutebrowser.utils # for test_qualname
-from qutebrowser.utils import utils, version, usertypes
+from qutebrowser.utils import utils, usertypes
from qutebrowser.utils.utils import VersionNumber
@@ -758,20 +758,7 @@ class TestOpenFile:
r"Opening /foo/bar with the system application", result)
openurl_mock.assert_called_with(QUrl('file:///foo/bar'))
- @pytest.fixture
- def sandbox_patch(self, monkeypatch):
- info = version.DistributionInfo(
- id='org.kde.Platform',
- parsed=version.Distribution.kde_flatpak,
- version=VersionNumber.parse('5.12'),
- pretty='Unknown')
-
- if not version.is_flatpak():
- monkeypatch.setattr(version, 'distribution', lambda: info)
-
- assert version.is_flatpak()
-
- def test_cmdline_sandboxed(self, sandbox_patch,
+ def test_cmdline_sandboxed(self, fake_flatpak,
config_stub, message_mock, caplog):
with caplog.at_level(logging.ERROR):
utils.open_file('/foo/bar', 'custom_cmd')
@@ -779,7 +766,7 @@ class TestOpenFile:
assert msg.text == 'Cannot spawn download dispatcher from sandbox'
@pytest.mark.not_frozen
- def test_setting_override_sandboxed(self, sandbox_patch, openurl_mock,
+ def test_setting_override_sandboxed(self, fake_flatpak, openurl_mock,
caplog, config_stub):
config_stub.val.downloads.open_dispatcher = 'test'
@@ -791,7 +778,7 @@ class TestOpenFile:
openurl_mock.assert_called_with(QUrl('file:///foo/bar'))
def test_system_default_sandboxed(self, config_stub, openurl_mock,
- sandbox_patch):
+ fake_flatpak):
utils.open_file('/foo/bar')
openurl_mock.assert_called_with(QUrl('file:///foo/bar'))