예제 #1
0
 def test_runtimedir_empty_tempdir(self, monkeypatch, tmpdir):
     """With an empty tempdir on non-Linux, we should raise."""
     monkeypatch.setattr(standarddir.sys, 'platform', 'nt')
     monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
                         lambda typ: '')
     with pytest.raises(standarddir.EmptyValueError):
         standarddir._init_runtime(args=None)
예제 #2
0
 def test_runtimedir_empty_tempdir(self, monkeypatch, tmpdir):
     """With an empty tempdir on non-Linux, we should raise."""
     monkeypatch.setattr(standarddir.sys, 'platform', 'nt')
     monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
                         lambda typ: '')
     with pytest.raises(standarddir.EmptyValueError):
         standarddir._init_runtime(args=None)
예제 #3
0
    def test_linux_invalid_runtimedir(self, monkeypatch, tmpdir):
        """With invalid XDG_RUNTIME_DIR, fall back to TempLocation."""
        tmpdir_env = tmpdir / 'temp'
        tmpdir_env.ensure(dir=True)
        monkeypatch.setenv('XDG_RUNTIME_DIR', str(tmpdir / 'does-not-exist'))
        monkeypatch.setenv('TMPDIR', str(tmpdir_env))

        standarddir._init_runtime(args=None)
        assert standarddir.runtime() == str(tmpdir_env / APPNAME)
예제 #4
0
    def test_flatpak_runtimedir(self, monkeypatch, tmp_path):
        runtime_path = tmp_path / 'runtime'
        runtime_path.mkdir()
        runtime_path.chmod(0o0700)

        app_id = 'org.qutebrowser.qutebrowser'
        expected = runtime_path / 'app' / app_id

        monkeypatch.setattr(standarddir.version, 'is_flatpak', lambda: True)
        monkeypatch.setenv('XDG_RUNTIME_DIR', str(runtime_path))
        monkeypatch.setenv('FLATPAK_ID', app_id)

        standarddir._init_runtime(args=None)
        assert standarddir.runtime() == str(expected)
    def test_flatpak_runtimedir(self, fake_flatpak, monkeypatch, tmp_path,
                                args_basedir):
        runtime_path = tmp_path / 'runtime'
        runtime_path.mkdir()
        runtime_path.chmod(0o0700)
        monkeypatch.setenv('XDG_RUNTIME_DIR', str(runtime_path))

        if args_basedir:
            init_args = types.SimpleNamespace(basedir=str(tmp_path))
            expected = tmp_path / 'runtime'
        else:
            init_args = None
            expected = runtime_path / 'app' / 'org.qutebrowser.qutebrowser'

        standarddir._init_runtime(args=init_args)
        assert standarddir.runtime() == str(expected)
예제 #6
0
    def test_flatpak_runtimedir(self, 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

        standarddir._init_runtime(args=init_args)
        assert standarddir.runtime() == str(expected)
예제 #7
0
def fake_runtime_dir(monkeypatch, short_tmpdir):
    monkeypatch.setenv('XDG_RUNTIME_DIR', str(short_tmpdir))
    standarddir._init_runtime(args=None)
    return short_tmpdir