diff --git a/tests/conftest.py b/tests/conftest.py index 4692d25f1bf..10c5617d1a6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,7 +15,9 @@ import keyring import pytest +from keyring import backends from keyring.backend import KeyringBackend +from keyring.errors import KeyringError from keyring.errors import KeyringLocked from poetry.config.config import Config as BaseConfig @@ -133,10 +135,6 @@ 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: diff --git a/tests/utils/test_authenticator.py b/tests/utils/test_authenticator.py index 08dbbb78d47..cda447fa479 100644 --- a/tests/utils/test_authenticator.py +++ b/tests/utils/test_authenticator.py @@ -107,6 +107,19 @@ def test_authenticator_ignores_locked_keyring( assert request.headers["Authorization"] == "Basic Zm9vMDAxOg==" +def test_authenticator_ignores_failing_keyring( + mock_config: Config, + mock_remote: None, + http: type[httpretty.httpretty], + with_erroneous_keyring: None, +) -> None: + authenticator = Authenticator(mock_config, NullIO()) + authenticator.request("get", "https://foo001@foo.bar/files/foo-0.1.0.tar.gz") + request = http.last_request() + + assert request.headers["Authorization"] == "Basic Zm9vMDAxOg==" + + def test_authenticator_uses_password_only_credentials( mock_config: Config, mock_remote: None, http: type[httpretty.httpretty] ) -> None: