Skip to content

Commit

Permalink
tests: Fix call assertion
Browse files Browse the repository at this point in the history
Under py312, MagicMock.has_calls raises an AttributeError. This is
actually a good thing, as previously we weren't actually making the
assertions we thought we were making.

Fix the one place that we forgot the leading `assert_`, and switch it
to `any_order=True`; this is required for the test to pass, as there
are additional calls between the two expected calls.

See python/cpython@1d4d677d

Change-Id: Ia2ff2f198b4c1312a3e7dce32f11b87050683d45
  • Loading branch information
tipabu committed Dec 15, 2023
1 parent 44f1138 commit 6f01f84
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/unit/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,12 +867,13 @@ def test_upload(self, connection, walk):
fh.write(b'12345678901234567890')
swiftclient.shell.main(argv)
expected_calls = [mock.call('container',
{'X-Storage-Policy': mock.ANY},
{'X-Storage-Policy': 'one'},
response_dict={}),
mock.call('container_segments',
{'X-Storage-Policy': mock.ANY},
{'X-Storage-Policy': 'one'},
response_dict={})]
connection.return_value.put_container.has_calls(expected_calls)
connection.return_value.put_container.assert_has_calls(expected_calls,
any_order=True)
connection.return_value.put_object.assert_called_with(
'container',
self.tmpfile.lstrip('/'),
Expand Down

0 comments on commit 6f01f84

Please sign in to comment.