Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint after ruff update #2680

Merged
merged 2 commits into from
Nov 25, 2024
Merged
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
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
Comment on lines +60 to +62
Copy link
Contributor Author

@Wauplin Wauplin Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less elegant that the previous version but ruff was formatting it in a way that was not supported in Python3.8 . I went for the easiest solution



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
Loading