Skip to content

Commit

Permalink
Fix unittest checking for Git calls
Browse files Browse the repository at this point in the history
This happened to work previously, since mock.has_calls existed, but apparently
only returned a bool. This has been removed in Python 3.12; use the correct
assert_has_calls instead, and fix the calls we assert to be there.
  • Loading branch information
TimoWilken committed Nov 8, 2023
1 parent 2005f80 commit bd2d66f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ def test_coverDoBuild(self, mock_debug, mock_glob, mock_sys, mock_git_git):
clone_args, clone_dir, clone_check = GIT_CLONE_ZLIB_ARGS
fetch_args, fetch_dir, fetch_check = GIT_FETCH_ROOT_ARGS
common_calls = [
call(("rev-parse", "HEAD"), args.configDir),
call(list(clone_args), directory=clone_dir, check=clone_check, prompt=False),
call(["ls-remote", "--heads", "--tags", args.referenceSources + "/zlib"],
directory=".", check=False, prompt=False),
call(["clone", "--bare", "https://github.com/star-externals/zlib", "/sw/MIRROR/zlib", "--filter=blob:none"]),
call(["ls-remote", "--heads", "--tags", args.referenceSources + "/root"],
directory=".", check=False, prompt=False),
]
Expand All @@ -290,7 +290,7 @@ def test_coverDoBuild(self, mock_debug, mock_glob, mock_sys, mock_git_git):
self.assertEqual(exit_code, 0)
mock_debug.assert_called_with("Everything done")
self.assertEqual(mock_git_git.call_count, len(common_calls))
mock_git_git.has_calls(common_calls)
mock_git_git.assert_has_calls(common_calls, any_order=True)

# Force fetching repos
mock_git_git.reset_mock()
Expand All @@ -303,9 +303,9 @@ def test_coverDoBuild(self, mock_debug, mock_glob, mock_sys, mock_git_git):
# We can't compare directly against the list of calls here as they
# might happen in any order.
self.assertEqual(mock_git_git.call_count, len(common_calls) + 1)
mock_git_git.has_calls(common_calls + [
call(fetch_args, directory=fetch_dir, check=fetch_check),
])
mock_git_git.assert_has_calls(common_calls + [
call(list(fetch_args), directory=fetch_dir, check=fetch_check, prompt=False),
], any_order=True)

def test_hashing(self):
"""Check that the hashes assigned to packages remain constant."""
Expand Down

0 comments on commit bd2d66f

Please sign in to comment.