Skip to content

Commit 572f93c

Browse files
committed
Use more specific log messages
1 parent 6612f8f commit 572f93c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

tests/test_auth.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ def get_credential(system, username):
140140
assert auth.Resolver(config, auth.CredentialInput()).username == "entered user"
141141

142142
assert re.search(
143-
r"Error from keyring.+Traceback.+RuntimeError: fail!", caplog.text, re.DOTALL
143+
r"Error getting username from keyring.+Traceback.+RuntimeError: fail!",
144+
caplog.text,
145+
re.DOTALL,
144146
)
145147

146148

@@ -159,7 +161,9 @@ def get_password(system, username):
159161
assert auth.Resolver(config, auth.CredentialInput()).password == "entered pw"
160162

161163
assert re.search(
162-
r"Error from keyring.+Traceback.+RuntimeError: fail!", caplog.text, re.DOTALL
164+
r"Error getting password from keyring.+Traceback.+RuntimeError: fail!",
165+
caplog.text,
166+
re.DOTALL,
163167
)
164168

165169

@@ -184,7 +188,7 @@ def get_credential(system, username):
184188
assert auth.Resolver(config, auth.CredentialInput()).username == "entered user"
185189

186190
assert re.search(
187-
r"Error from keyring"
191+
r"Error getting username from keyring"
188192
r".+Traceback"
189193
r".+KeyError: 'HOME'"
190194
r".+KeyError: 'uid not found: 999'",
@@ -206,7 +210,7 @@ def get_password(system, username):
206210
assert auth.Resolver(config, auth.CredentialInput()).password == "entered pw"
207211

208212
assert re.search(
209-
r"Error from keyring"
213+
r"Error getting password from keyring"
210214
r".+Traceback"
211215
r".+KeyError: 'HOME'"
212216
r".+KeyError: 'uid not found: 999'",

twine/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_username_from_keyring(self) -> Optional[str]:
6363
# To support keyring prior to 15.2
6464
pass
6565
except Exception as exc:
66-
logger.warning("Error from keyring", exc_info=exc)
66+
logger.warning("Error getting username from keyring", exc_info=exc)
6767
return None
6868

6969
def get_password_from_keyring(self) -> Optional[str]:
@@ -73,7 +73,7 @@ def get_password_from_keyring(self) -> Optional[str]:
7373
logger.info("Querying keyring for password")
7474
return cast(str, keyring.get_password(system, username))
7575
except Exception as exc:
76-
logger.warning("Error from keyring", exc_info=exc)
76+
logger.warning("Error getting password from keyring", exc_info=exc)
7777
return None
7878

7979
def username_from_keyring_or_prompt(self) -> str:

0 commit comments

Comments
 (0)