Skip to content

Commit

Permalink
WIP erroneous backend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
real-yfprojects committed Sep 3, 2023
1 parent 9f868fc commit ca38ef4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ def delete_password(self, service: str, username: str | None) -> None:
raise KeyringLocked()


from keyring import backends
from keyring.errors import KeyringError


class ErroneousBackend(backends.fail.Keyring):
@classmethod
def priority(cls) -> int:
return 42

def get_credential(self, service: str, username: str | None) -> Any:
raise KeyringError()


@pytest.fixture()
def dummy_keyring() -> DummyBackend:
return DummyBackend()
Expand All @@ -155,6 +168,11 @@ def with_locked_keyring() -> None:
keyring.set_keyring(LockedBackend()) # type: ignore[no-untyped-call]


@pytest.fixture()
def with_erroneous_keyring() -> None:
keyring.set_keyring(ErroneousBackend()) # type: ignore[no-untyped-call]


@pytest.fixture()
def with_null_keyring() -> None:
from keyring.backends.null import Keyring
Expand Down
6 changes: 6 additions & 0 deletions tests/utils/test_password_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ def test_locked_keyring_should_be_available(with_locked_keyring: None) -> None:
assert key_ring.is_available()


def test_erroneous_keyring_should_be_available(with_erroneous_keyring: None) -> None:
key_ring = PoetryKeyring("poetry")

assert key_ring.is_available()


def test_get_http_auth_from_environment_variables(
environ: None, config: Config
) -> None:
Expand Down

0 comments on commit ca38ef4

Please sign in to comment.