Skip to content

Commit

Permalink
Merge branch 'main' into make-sure-create-repo-respects-default-setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin authored Nov 25, 2024
2 parents eeda6eb + 7dc41b1 commit aac0f70
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/test_auth_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ def mock_stored_tokens():
"token2": "hf_5678",
"active_token": "hf_9012",
}
with patch("huggingface_hub._login.get_stored_tokens", return_value=stored_tokens), patch(
"huggingface_hub.utils._auth.get_stored_tokens", return_value=stored_tokens
):
yield stored_tokens
with patch("huggingface_hub._login.get_stored_tokens", return_value=stored_tokens):
with patch("huggingface_hub.utils._auth.get_stored_tokens", return_value=stored_tokens):
yield stored_tokens


def assert_in_logs(caplog: LogCaptureFixture, expected_output):
Expand Down Expand Up @@ -89,10 +88,9 @@ def test_login_command_with_git(mock_whoami_api_call, caplog: LogCaptureFixture)
args = type("Args", (), {"token": MOCK_TOKEN, "add_to_git_credential": True})()
cmd = LoginCommand(args)

with patch("huggingface_hub._login._is_git_credential_helper_configured", return_value=True), patch(
"huggingface_hub.utils.set_git_credential"
):
cmd.run()
with patch("huggingface_hub._login._is_git_credential_helper_configured", return_value=True):
with patch("huggingface_hub.utils.set_git_credential"):
cmd.run()

assert_in_logs(caplog, "Login successful")
assert_in_logs(caplog, "Your token has been saved in your configured git credential helpers")
Expand Down

0 comments on commit aac0f70

Please sign in to comment.