Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions keyring/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os
import typing
import warnings
from collections.abc import Callable

from jaraco.context import ExceptionTrap
from jaraco.functools import once
Expand All @@ -23,8 +24,8 @@
log = logging.getLogger(__name__)


by_priority = operator.attrgetter('priority')
_limit: typing.Callable[[KeyringBackend], bool] | None = None
by_priority: Callable[[KeyringBackend | type[KeyringBackend]], float] = operator.attrgetter('priority')
_limit: Callable[[KeyringBackend], bool] | None = None


class KeyringBackendMeta(abc.ABCMeta):
Expand Down
24 changes: 24 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,27 @@ def test_get(monkeypatch, mocked_get_credential, format, capsys):
tool.output_format = format
tool.do_get()
assert 's3cret' in capsys.readouterr().out


def test_set_missing_service():
tool = cli.CommandLineTool()
with pytest.raises(SystemExit):
tool.run(['set'])


def test_set_missing_username():
tool = cli.CommandLineTool()
with pytest.raises(SystemExit):
tool.run(['set', 'svc'])


def test_get_password_missing_username():
tool = cli.CommandLineTool()
with pytest.raises(SystemExit):
tool.run(['get', 'svc'])


def test_invalid_backend():
tool = cli.CommandLineTool()
with pytest.raises(SystemExit):
tool.run(['-b', 'nonexistent.backend', 'get', 'svc', 'usr'])