[go: nahoru, domu]

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

Replace mock_obj.assert_has_calls(calls) with assert mock_obj.mock_calls == calls #12480

Closed
harupy opened this issue Jun 26, 2024 · 4 comments
Closed
Assignees
Labels
good first issue Good for newcomers

Comments

@harupy
Copy link
Member
harupy commented Jun 26, 2024

Summary

assert_has_calls is not exact match and can lead to false positives:

diff --git a/tests/store/artifact/test_databricks_artifact_repo.py b/tests/store/artifact/test_databricks_artifact_repo.py
index 733db7bd3..5fc20d681 100644
--- a/tests/store/artifact/test_databricks_artifact_repo.py
+++ b/tests/store/artifact/test_databricks_artifact_repo.py
@@ -722,7 +722,7 @@ def test_list_artifacts_handles_pagination(databricks_artifact_repo):
             mock.call(ListArtifacts(run_id=MOCK_RUN_ID, path="", page_token="4")),
             mock.call(ListArtifacts(run_id=MOCK_RUN_ID, path="", page_token="6")),
         ]
-        message_mock.assert_has_calls(calls)
+        assert message_mock.mock_calls == calls
 
 
 def test_get_read_credential_infos_handles_pagination(databricks_artifact_repo):

In most cases, assert mock_obj.mock_calls == calls should work.

Notes

  • Make sure to open a PR from a non-master branch.

  • Sign off the commit using the -s flag when making a commit:

    git commit -s -m "..."
             # ^^ make sure to use this
  • Include #{issue_number} (e.g. #123) in the PR description when opening a PR.

@harupy harupy added the good first issue Good for newcomers label Jun 26, 2024
@harupy harupy changed the title Replace mock.assert_has_calls(calls) with assert mock.mock_calls == calls Replace mock_obj.assert_has_calls(calls) with assert mock_obj.mock_calls == calls Jun 26, 2024
@Jaishree2310
Copy link
Contributor

Hey @harupy, can you please assign this issue to me?
Thanks!

@harupy
Copy link
Member Author
harupy commented Jun 26, 2024

@Jaishree2310 thanks!

Copy link
github-actions bot commented Jul 4, 2024

@mlflow/mlflow-team Please assign a maintainer and start triaging this issue.

@harupy
Copy link
Member Author
harupy commented Jul 4, 2024

Resolved by #12512

@harupy harupy closed this as completed Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants