Skip to content

Commit a64c4d9

Browse files
committed
Fix missing assert_ prefix on called_with
test_clean_storage_unmount incorrectly used 'called_with' instead of 'assert_called_with' which just made a mock function call and didn't check or assert that the function was actually called. As a result this function didn't actually test anything, the expected parameters were not correct so they have been updated. An error to catch this accidental mistake was added in the recently released mock 5.0.1 (python/cpython#100690) AttributeError: 'called_with' is not a valid assertion. Use a spec for the mock if 'called_with' is meant to be an attribute. The mock library ships in python as unittest.mock but also publishes the latest code as the 'mock' python package so that older python versions can get the latest code. The stable branches currently install mock but the master branch does not, so this error does not actually appear on master but only the <=yoga stable branches currently. The test is however wrong either way. Change-Id: I3076778e8fc62c086651d29abb2c5a3d9921be97
1 parent d9a6ed5 commit a64c4d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

unit_tests/test_cinder_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def test_clean_storage_unmount(self):
405405
self.zap_disk.return_value = True
406406
self.mounts.return_value = MOUNTS
407407
cinder_utils.clean_storage('/dev/fakevbd')
408-
self.umount.called_with('/dev/fakevbd', True)
408+
self.umount.assert_called_with('/mnt', persist=True)
409409

410410
def test_clean_storage_lvm_wipe(self):
411411
'It removes traces of LVM when cleaning storage'

0 commit comments

Comments
 (0)