| Server IP : 189.126.111.107 / Your IP : 216.73.217.69 Web Server : Apache System : Linux www.gadotticar.com.br 5.4.0-135-generic #152-Ubuntu SMP Wed Nov 23 20:19:22 UTC 2022 x86_64 User : gadotticar ( 1000) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/keyring/tests/backends/ |
Upload File : |
import pytest
import keyring.backends.chainer
from keyring import backend
@pytest.fixture
def two_keyrings(monkeypatch):
def get_two():
class Keyring1(backend.KeyringBackend):
priority = 1
def get_password(self, system, user):
return 'ring1-{system}-{user}'.format(**locals())
def set_password(self, system, user, password):
pass
class Keyring2(backend.KeyringBackend):
priority = 2
def get_password(self, system, user):
return 'ring2-{system}-{user}'.format(**locals())
def set_password(self, system, user, password):
raise NotImplementedError()
return Keyring1(), Keyring2()
monkeypatch.setattr('keyring.backend.get_all_keyring', get_two)
class TestChainer:
def test_chainer_gets_from_highest_priority(self, two_keyrings):
chainer = keyring.backends.chainer.ChainerBackend()
pw = chainer.get_password('alpha', 'bravo')
assert pw == 'ring2-alpha-bravo'