diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-03-31 09:50:25 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-03-31 13:10:09 +0200 |
commit | 8b49d87526dd34380df6e98800ecc82367b48be1 (patch) | |
tree | 2184c84afd80600965962a441d757ca6a85ba63f /tests | |
parent | 5a4b51a784b4332242191a61a24d72bca3ff60dc (diff) | |
download | qutebrowser-8b49d87526dd34380df6e98800ecc82367b48be1.tar.gz qutebrowser-8b49d87526dd34380df6e98800ecc82367b48be1.zip |
flatpak: Try getting ID from /.flatpak_info
Diffstat (limited to 'tests')
-rw-r--r-- | tests/helpers/fixtures.py | 10 | ||||
-rw-r--r-- | tests/unit/config/test_qtargs_locale_workaround.py | 2 | ||||
-rw-r--r-- | tests/unit/misc/test_ipc.py | 8 | ||||
-rw-r--r-- | tests/unit/utils/test_standarddir.py | 6 | ||||
-rw-r--r-- | tests/unit/utils/test_version.py | 34 |
5 files changed, 30 insertions, 30 deletions
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index 43959f246..7106698be 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -752,16 +752,6 @@ def freezer(request, monkeypatch): @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/config/test_qtargs_locale_workaround.py b/tests/unit/config/test_qtargs_locale_workaround.py index cbb657902..4a4152b80 100644 --- a/tests/unit/config/test_qtargs_locale_workaround.py +++ b/tests/unit/config/test_qtargs_locale_workaround.py @@ -448,7 +448,7 @@ def test_disabled(qtwe_version, config_stub): @pytest.mark.fake_os('linux') -def test_no_locales_available(qtwe_version, monkeypatch, caplog): +def test_no_locales_available(qtwe_version, monkeypatch, caplog, request): path = pathlib.Path('/doesnotexist/qtwebengine_locales') assert not path.exists() monkeypatch.setattr(qtargs, '_webengine_locales_path', lambda: path) diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index e93578853..51d7c6343 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -236,8 +236,14 @@ class TestSocketName: (None, 'ipc-{}'.format(md5('testusername'))), ('/x', 'ipc-{}'.format(md5('testusername-/x'))), ]) + @pytest.mark.parametrize('has_flatpak_id', [True, False]) @pytest.mark.skipif(not version.is_flatpak(), reason="Needs Flatpak") - def test_flatpak(self, basedir, fake_runtime_dir, expected): + def test_flatpak(self, monkeypatch, fake_runtime_dir, + basedir, expected, has_flatpak_id): + if not has_flatpak_id: + # Simulate an older Flatpak version + monkeypatch.delenv('FLATPAK_ID', raising=False) + socketname = ipc._get_socketname(basedir) expected_path = str( fake_runtime_dir / 'app' / 'org.qutebrowser.qutebrowser' / expected) diff --git a/tests/unit/utils/test_standarddir.py b/tests/unit/utils/test_standarddir.py index fd7fd9c9e..e05b5d31f 100644 --- a/tests/unit/utils/test_standarddir.py +++ b/tests/unit/utils/test_standarddir.py @@ -209,15 +209,11 @@ class TestStandardDir: @pytest.mark.linux @pytest.mark.parametrize('args_basedir', [True, False]) - @pytest.mark.parametrize('has_flatpak_id', [True, False]) def test_flatpak_runtimedir(self, fake_flatpak, monkeypatch, tmp_path, - args_basedir, has_flatpak_id): + args_basedir): runtime_path = tmp_path / 'runtime' runtime_path.mkdir() runtime_path.chmod(0o0700) - - if not has_flatpak_id: - monkeypatch.delenv('FLATPAK_ID') # added in fake_flatpak monkeypatch.setenv('XDG_RUNTIME_DIR', str(runtime_path)) if args_basedir: diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py index 399b8380d..14d7786a8 100644 --- a/tests/unit/utils/test_version.py +++ b/tests/unit/utils/test_version.py @@ -310,19 +310,27 @@ def test_distribution(tmp_path, monkeypatch, os_release, expected): assert version.distribution() == expected -@pytest.mark.parametrize('distribution, expected', [ - (None, False), - (version.DistributionInfo( - id='org.kde.Platform', parsed=version.Distribution.kde_flatpak, - version=utils.VersionNumber(5, 12), - pretty='Unknown'), True), - (version.DistributionInfo( - id='arch', parsed=version.Distribution.arch, version=None, - pretty='Arch Linux'), False) -]) -def test_is_flatpak(monkeypatch, distribution, expected): - monkeypatch.setattr(version, "distribution", lambda: distribution) - assert version.is_flatpak() == expected +@pytest.mark.parametrize('has_env', [True, False]) +@pytest.mark.parametrize('has_file', [True, False]) +def test_is_flatpak(monkeypatch, tmp_path, has_env, has_file): + if has_env: + monkeypatch.setenv('FLATPAK_ID', 'org.qutebrowser.qutebrowser') + else: + monkeypatch.delenv('FLATPAK_ID', raising=False) + + fake_info_path = tmp_path / '.flatpak_info' + if has_file: + lines = [ + "[Application]", + "name=org.qutebrowser.qutebrowser", + "runtime=runtime/org.kde.Platform/x86_64/5.15", + ] + fake_info_path.write_text('\n'.join(lines)) + else: + assert not fake_info_path.exists() + monkeypatch.setattr(version, '_FLATPAK_INFO_PATH', str(fake_info_path)) + + assert version.is_flatpak() == (has_env or has_file) class GitStrSubprocessFake: |