File: test_libsecret.py

package info (click to toggle)
python-keyring 25.6.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 560 kB
  • sloc: python: 1,929; sh: 17; makefile: 17
file content (31 lines) | stat: -rw-r--r-- 876 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pytest

from keyring.backends import libsecret
from keyring.testing.backend import BackendBasicTests
from keyring.testing.util import NoNoneDictMutator


@pytest.mark.skipif(
    not libsecret.Keyring.viable,
    reason="libsecret package is needed for LibSecretKeyring",
)
class TestLibSecretKeyring(BackendBasicTests):
    __test__ = True

    def init_keyring(self):
        print(
            "Testing LibSecretKeyring; the following "
            "password prompts are for this keyring"
        )
        keyring = libsecret.Keyring()
        keyring.collection = 'session'
        return keyring


class TestUnits:
    def test_supported_no_libsecret(self):
        """
        LibSecretKeyring is not viable if Secret can't be imported.
        """
        with NoNoneDictMutator(libsecret.__dict__, Secret=None):
            assert not libsecret.Keyring.viable